package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Quaternion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.badlogic.gdx.utils.ScreenUtils;
import com.corona.Game;
import com.corona.game.util.LinkedMusic;
import com.corona.game.util.SpriteProxy;
import com.corona.game.util.TextureCache;
import com.corona.game.util.audio.AudioLoader;
import com.sun.jna.platform.win32.COM.tlb.imp.TlbConst;
import com.sun.jna.platform.win32.WinError;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Objects;
import org.lwjgl.system.windows.User32;
import oshi.util.Constants;

/* loaded from: pokewilds.jar:com/pkmngen/game/Battle.class */
public class Battle {
    public static HashMap<String, Attack.Category> specPhysLookup = new HashMap<>();
    public static ArrayList<String> gen2PhysicalTypes;
    public Pokemon oppPokemon;
    DrawBattle drawAction;
    Music music;
    Music victoryFanfare;
    HashMap<String, HashMap<String, Float>> gen2TypeEffectiveness;
    Runnable runnable;
    public String weather;
    HashMap<String, Attack> attacks = new HashMap<>();
    Network network = new Network();
    public int turnNumber = 1;
    public Pokemon.Generation generation = Pokemon.Generation.CRYSTAL;
    public boolean playerReflectDown = false;
    public boolean oppReflectDown = false;
    public int playerReflectCounter = 0;
    public int oppReflectCounter = 0;
    public boolean playerLightScreenDown = false;
    public boolean oppLightScreenDown = false;
    public int playerLightScreenCounter = 0;
    public int oppLightScreenCounter = 0;
    public int weatherCounter = 0;
    public boolean playerAirborne = false;
    public boolean playerUnderground = false;
    public boolean oppAirborne = false;
    public boolean oppUnderground = false;
    public boolean playerSafeguardDown = false;
    public int playerSafeguardCounter = 0;
    public boolean oppSafeguardDown = false;
    public int oppSafeguardCounter = 0;
    public int playerLockedMove = -1;
    public int playerLockedMoveCounter = 0;
    public int oppLockedMove = -1;
    public int oppLockedMoveCounter = 0;
    public boolean playerSpikesDown = false;
    public boolean oppSpikesDown = false;

    static {
        try {
            Reader reader = Gdx.files.internal("pokemon/spec_phys_lookup.txt").reader();
            BufferedReader br = new BufferedReader(reader);
            while (true) {
                String line = br.readLine();
                if (line == null) {
                    break;
                }
                String[] attrs = line.split(",");
                specPhysLookup.put(attrs[0].toLowerCase(Locale.ROOT).replace("_", " "), Attack.Category.valueOf(attrs[1]));
            }
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        gen2PhysicalTypes = new ArrayList<>();
        gen2PhysicalTypes.add("normal");
        gen2PhysicalTypes.add("fighting");
        gen2PhysicalTypes.add("poison");
        gen2PhysicalTypes.add("ground");
        gen2PhysicalTypes.add("flying");
        gen2PhysicalTypes.add("bug");
        gen2PhysicalTypes.add("rock");
        gen2PhysicalTypes.add("ghost");
        gen2PhysicalTypes.add("steel");
    }

    public static int gen2CalcDamage(Pokemon source, Attack attack, Pokemon target) {
        if (attack.name.equals("Mewtwo_Special1")) {
            float multiplier = 1.0f;
            String prevType = "";
            Iterator<String> it = target.types.iterator();
            while (it.hasNext()) {
                String type = it.next();
                if (!type.equals(prevType)) {
                    prevType = type;
                    multiplier *= Game.staticGame.battle.gen2TypeEffectiveness.get(attack.type).get(type.toLowerCase(Locale.ROOT)).floatValue();
                }
            }
            return (int) (30.0f * multiplier);
        } else if (attack.name.equals("Regigigas_Special1")) {
            float multiplier2 = 1.0f;
            String prevType2 = "";
            Iterator<String> it2 = target.types.iterator();
            while (it2.hasNext()) {
                String type2 = it2.next();
                if (!type2.equals(prevType2)) {
                    prevType2 = type2;
                    multiplier2 *= Game.staticGame.battle.gen2TypeEffectiveness.get(attack.type).get(type2.toLowerCase(Locale.ROOT)).floatValue();
                }
            }
            return (int) (30.0f * multiplier2);
        } else {
            int power = attack.power;
            if (attack.name.equals("dragon energy")) {
                power = (power * source.currentStats.get("hp").intValue()) / source.maxStats.get("hp").intValue();
                if (power < 1) {
                    power = 1;
                }
            } else if (attack.name.equals("crush grip")) {
                power = 1 + ((120 * target.currentStats.get("hp").intValue()) / target.maxStats.get("hp").intValue());
            }
            if (attack.name.equals("rollout")) {
                int lockedMoveCounter = Game.staticGame.battle.oppLockedMoveCounter;
                String prevAttack = null;
                if (DrawBattle.prevEnemyAttackIndex != -1) {
                    prevAttack = Game.staticGame.battle.oppPokemon.attacks[DrawBattle.prevEnemyAttackIndex];
                }
                System.out.println();
                if (target == Game.staticGame.battle.oppPokemon) {
                    lockedMoveCounter = Game.staticGame.battle.playerLockedMoveCounter;
                    if (DrawBattle.prevFriendlyAttackIndex != -1) {
                        prevAttack = Game.staticGame.player.currPokemon.attacks[DrawBattle.prevFriendlyAttackIndex];
                    }
                }
                if (prevAttack != null && prevAttack.equals("defense curl")) {
                    power *= 2;
                }
                for (int i = 1; i < 6 - lockedMoveCounter; i++) {
                    power *= 2;
                }
            }
            if (attack.effect.equals("EFFECT_LEVEL_DAMAGE") || attack.effect.equals("EFFECT_STATIC_DAMAGE") || attack.effect.equals("EFFECT_PSYWAVE")) {
                int damage = 0;
                if (attack.effect.equals("EFFECT_LEVEL_DAMAGE")) {
                    damage = source.level;
                } else if (attack.effect.equals("EFFECT_STATIC_DAMAGE")) {
                    damage = attack.power;
                } else if (attack.effect.equals("EFFECT_PSYWAVE")) {
                    damage = Game.rand.nextInt((int) (((float) source.level) * 1.5f));
                    if (damage <= 0) {
                        damage = 1;
                    }
                }
                float multiplier3 = 1.0f;
                String prevType3 = "";
                Iterator<String> it3 = target.types.iterator();
                while (it3.hasNext()) {
                    String type3 = it3.next();
                    if (!type3.equals(prevType3)) {
                        prevType3 = type3;
                        multiplier3 *= Game.staticGame.battle.gen2TypeEffectiveness.get(attack.type).get(type3.toLowerCase(Locale.ROOT)).floatValue();
                    }
                }
                if (multiplier3 != 0.0f) {
                    multiplier3 = 1.0f;
                }
                int damage2 = (int) (((float) damage) * multiplier3);
                System.out.println(attack.name + " " + damage2);
                return damage2;
            }
            int attackStat = (attack.isPhysical ? source.currentStats.get("attack") : source.currentStats.get("specialAtk")).intValue();
            int defenseStat = (attack.isPhysical ? target.currentStats.get("defense") : target.currentStats.get("specialDef")).intValue();
            if (attack.isCrit) {
                if ((attack.isPhysical ? source.statStages.get("attack") : source.statStages.get("specialAtk")).intValue() >= (attack.isPhysical ? target.statStages.get("attack") : target.statStages.get("specialAtk")).intValue()) {
                    attackStat = (attack.isPhysical ? source.maxStats.get("attack") : source.maxStats.get("specialAtk")).intValue();
                    defenseStat = (attack.isPhysical ? target.maxStats.get("defense") : target.maxStats.get("specialDef")).intValue();
                }
            }
            if (attack.effect.equals("EFFECT_SELFDESTRUCT")) {
                defenseStat /= 2;
            }
            int damage3 = ((int) Math.floor(Math.floor(((Math.floor((double) (((2 * source.level) / 5) + 2)) * ((double) attackStat)) * ((double) power)) / ((double) defenseStat)) / 50.0d)) + 2;
            if (attack.isCrit) {
                damage3 *= 2;
            }
            boolean targetAirborne = false;
            boolean targetUnderground = false;
            if (target == Game.staticGame.battle.oppPokemon) {
                targetAirborne = Game.staticGame.battle.oppAirborne;
                targetUnderground = Game.staticGame.battle.oppUnderground;
            } else if (target == Game.staticGame.player.currPokemon) {
                targetAirborne = Game.staticGame.battle.playerAirborne;
                targetUnderground = Game.staticGame.battle.playerUnderground;
            }
            if ((attack.effect.equals("EFFECT_TWISTER") || attack.name.equals("gust")) && targetAirborne) {
                damage3 *= 2;
            }
            if ((attack.effect.equals("EFFECT_EARTHQUAKE") || attack.effect.equals("EFFECT_MAGNITUDE")) && targetUnderground) {
                damage3 *= 2;
            }
            if (damage3 > 997) {
                damage3 = 997;
            }
            int damage4 = damage3 + 2;
            if (source.types.contains(attack.type.toUpperCase(Locale.ROOT))) {
                damage4 = (int) (((float) damage4) * 1.5f);
            }
            float multiplier4 = 1.0f;
            String prevType4 = "";
            Iterator<String> it4 = target.types.iterator();
            while (it4.hasNext()) {
                String type4 = it4.next();
                if (!type4.equals(prevType4)) {
                    prevType4 = type4;
                    multiplier4 *= Game.staticGame.battle.gen2TypeEffectiveness.get(attack.type).get(type4.toLowerCase(Locale.ROOT)).floatValue();
                }
            }
            return (((int) (((float) damage4) * multiplier4)) * (Game.rand.nextInt(39) + WinError.ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY)) / 255;
        }
    }

    static boolean gen2DetermineCrit(Pokemon source, Attack attack) {
        int c;
        int c2 = 0;
        if (attack.name.equals("aero blast") || attack.name.equals("crabhammer") || attack.name.equals("cross chop") || attack.name.equals("karate chop") || attack.name.equals("razor leaf") || attack.name.equals("slash")) {
            c2 = 0 + 2;
        } else if (attack.name.equals("air cutter")) {
            c2 = 0 + 1;
        }
        if (c2 == 0) {
            c = 17;
        } else if (c2 == 1) {
            c = 32;
        } else if (c2 == 2) {
            c = 64;
        } else if (c2 == 3) {
            c = 85;
        } else {
            c = 128;
        }
        return Game.staticGame.map.rand.nextInt(256) < c;
    }

    @Deprecated
    public static Action calcIfCaught(Game game, Action nextAction) {
        boolean breaksFree;
        int randomNum = game.map.rand.nextInt(150 + 1);
        int adrenaline = game.player.adrenaline;
        if (adrenaline > 25) {
            adrenaline = 25;
        }
        int f = (int) Math.floor((double) (((game.battle.oppPokemon.currentStats.get("catchRate").intValue() * 255) * 4) / (100 * 15)));
        if (randomNum - 0 > game.battle.oppPokemon.currentStats.get("catchRate").intValue()) {
        }
        int randomNum_M = game.map.rand.nextInt(256);
        if (f + (adrenaline * 10) >= randomNum_M) {
            breaksFree = false;
        } else {
            breaksFree = true;
        }
        System.out.println("(randomNum_M / f / adr): (" + String.valueOf(randomNum_M) + " / " + String.valueOf(f) + " / +" + String.valueOf(adrenaline * 10) + ")");
        if (!breaksFree) {
            return new CatchPokemonWobblesThenCatch(game, "", nextAction);
        }
        int d = (game.battle.oppPokemon.currentStats.get("catchRate").intValue() * 100) / 150;
        if (d >= 256) {
            return new CatchPokemonWobbles3Times(game, new PrintAngryEating(game, new ChanceToRun(game, nextAction)));
        }
        int x = ((d * f) / 255) + 0;
        if (x < 10) {
            return new CatchPokemonMiss(game, new PrintAngryEating(game, new ChanceToRun(game, nextAction)));
        }
        if (x < 30) {
            return new CatchPokemonWobbles1Time(game, new PrintAngryEating(game, new ChanceToRun(game, nextAction)));
        }
        if (x < 70) {
            return new CatchPokemonWobbles2Times(game, new PrintAngryEating(game, new ChanceToRun(game, nextAction)));
        }
        return new CatchPokemonWobbles3Times(game, new PrintAngryEating(game, new ChanceToRun(game, nextAction)));
    }

    public static int gen2CalcIfCaught(Game game, Pokemon pokemon, String ballUsed) {
        String ballUsed2 = ballUsed.toLowerCase(Locale.ROOT);
        if (ballUsed2.equals("master ball")) {
            return -1;
        }
        int rateModified = pokemon.maxStats.get("catchRate").intValue();
        if (ballUsed2.equals("great ball") || ballUsed2.equals("park ball")) {
            rateModified = (int) (((float) rateModified) * 1.5f);
        } else if (ballUsed2.equals("ultra ball")) {
            rateModified *= 2;
        } else if (ballUsed2.equals("dusk ball")) {
            if (game.map.timeOfDay.equals("night") || game.map.tiles != game.map.overworldTiles) {
                rateModified = (int) (((float) rateModified) * 3.5f);
            }
        } else if (ballUsed2.equals("fast ball")) {
            if (pokemon.baseStats.get("speed").intValue() >= 100) {
                rateModified *= 4;
            }
        } else if (ballUsed2.equals("quick ball")) {
            if (game.battle.turnNumber == 1) {
                rateModified *= 5;
            }
        } else if (ballUsed2.equals("net ball")) {
            if (game.battle.oppPokemon.types.contains("WATER") || game.battle.oppPokemon.types.contains("BUG")) {
                rateModified = (int) (((float) rateModified) * Math.min(1.0f + (((float) game.battle.turnNumber) * 0.30004883f), 4.0f));
            }
        } else if (ballUsed2.equals("dive ball")) {
            if (game.player.currFieldMove.equals("SURF") || game.player.currRod != null) {
                rateModified = (int) (((float) rateModified) * 3.5f);
            }
        } else if (ballUsed2.equals("nest ball")) {
            if (game.battle.oppPokemon.level <= 29) {
                rateModified = (int) (((float) rateModified) * ((41.0f - ((float) game.battle.oppPokemon.level)) / 10.0f));
            }
        } else if (ballUsed2.equals("dream ball")) {
            if (game.battle.oppPokemon.status != null && game.battle.oppPokemon.status.equals("sleep")) {
                rateModified *= 4;
            }
        } else if (ballUsed2.equals("heavy ball")) {
            float weight = Pokemon.weights.get(pokemon.dexNumber).floatValue();
            int foundRate = rateModified + 30;
            if (weight < 100.0f) {
                foundRate = rateModified - 20;
            } else if (weight < 200.0f) {
                foundRate = rateModified;
            } else if (weight < 300.0f) {
                foundRate = rateModified + 20;
            }
            rateModified = foundRate;
        } else if (ballUsed2.equals("level ball")) {
            if (game.player.currPokemon.level / 4 > pokemon.level) {
                rateModified *= 8;
            } else if (game.player.currPokemon.level / 2 > pokemon.level) {
                rateModified *= 4;
            } else if (game.player.currPokemon.level > pokemon.level) {
                rateModified *= 2;
            }
        } else if (ballUsed2.equals("love ball")) {
            if ((!pokemon.gender.equals(Constants.UNKNOWN) && !game.player.currPokemon.gender.equals(Constants.UNKNOWN) && !game.player.currPokemon.gender.equals(pokemon.gender)) && game.player.currPokemon.specie.name.equals(pokemon.specie.name)) {
                rateModified *= 8;
            }
        } else if (ballUsed2.equals("moon ball")) {
            String[] moonStoneMons = {"clefairy", "jigglypuff", "nidorina", "nidorino"};
            int length = moonStoneMons.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    break;
                } else if (pokemon.specie.name.equals(moonStoneMons[i])) {
                    rateModified *= 4;
                    break;
                } else {
                    i++;
                }
            }
        }
        if (rateModified > 255) {
            rateModified = 255;
        }
        int bonusStatus = 0;
        if (pokemon.status != null && (pokemon.status.equals("sleep") || pokemon.status.equals("freeze"))) {
            bonusStatus = 10;
        }
        int m = 3 * pokemon.maxStats.get("hp").intValue();
        int h = 2 * pokemon.currentStats.get("hp").intValue();
        if (m > 255) {
            m = (m / 2) / 2;
            h = (h / 2) / 2;
        }
        int a = ((m - h) * rateModified) / m;
        if (a < 1) {
            a = 1;
        }
        int a2 = a + bonusStatus;
        if (a2 > 255) {
            a2 = 255;
        }
        System.out.println(a2);
        if (game.map.rand.nextInt(256) <= a2) {
            return -1;
        }
        int[] aLookup = {1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 40, 50, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 254, 255};
        int[] bLookup = {63, 75, 84, 90, 95, 103, 113, 126, 134, 149, 160, 169, 177, 191, 201, 211, 220, User32.VK_ICO_HELP, 234, 240, User32.VK_ATTN, User32.VK_ZOOM, User32.VK_PA1, 255};
        int i2 = 0;
        int prevVal = -1;
        for (int val : aLookup) {
            if (a2 > prevVal && a2 <= val) {
                break;
            }
            prevVal = val;
            i2++;
        }
        int b = bLookup[i2];
        if (game.map.rand.nextInt(256) >= b) {
            return 0;
        }
        if (game.map.rand.nextInt(256) >= b) {
            return 1;
        }
        if (game.map.rand.nextInt(256) >= b) {
            return 2;
        }
        return 3;
    }

    public static Action getAttackAction(Game game, Attack attack, boolean isFriendly, Action nextAction) {
        int accuracy;
        int power;
        Pokemon enemyPokemon;
        Pokemon friendlyPokemon;
        int previousAttackIndex;
        String text;
        String text2;
        String text3;
        String effectiveness;
        if (attack.name.equals("Aurora Beam")) {
            power = 65;
            accuracy = 100;
        } else if (attack.name.equals("Clamp")) {
            power = 35;
            accuracy = 85;
        } else if (attack.name.equals("Supersonic")) {
            power = 0;
            accuracy = 55;
        } else if (attack.name.equals("Withdraw")) {
            power = 20;
            accuracy = 100;
        } else if (attack.name.equals("Struggle")) {
            power = 50;
            accuracy = 100;
        } else if (attack.name.equals("Psychic")) {
            if (isFriendly) {
                return new Attack.Psychic(game, game.battle.oppPokemon, false, nextAction);
            }
            return new Attack.Psychic(game, game.player.currPokemon, false, nextAction);
        } else if (attack.name.equals("Mewtwo_Special1")) {
            return new Attack.Mewtwo_Special1(game, game.battle.oppPokemon, game.player.currPokemon, nextAction);
        } else {
            if (attack.name.equals("Night Shade")) {
                if (isFriendly) {
                    return new Attack.Psychic(game, game.battle.oppPokemon, true, nextAction);
                }
                return new Attack.Psychic(game, game.player.currPokemon, true, nextAction);
            } else if (attack.name.equals("Slash")) {
                if (isFriendly) {
                    return new Attack.Default(game, 40, 100, nextAction);
                }
                return new Attack.Slash(game, game.battle.oppPokemon, game.player.currPokemon, nextAction);
            } else if (attack.name.equals("Shadow Claw")) {
                if (isFriendly) {
                    return new Attack.Default(game, 40, 100, nextAction);
                }
                return new Attack.ShadowClaw(game, game.battle.oppPokemon, game.player.currPokemon, nextAction);
            } else if (!attack.name.equals("Lick")) {
                if (SpecialMewtwo1.class.isInstance(game.battle.oppPokemon) && !isFriendly) {
                    SpecialBattleMewtwo.specialAttackCounter++;
                    if (SpecialBattleMewtwo.specialAttackCounter >= 3) {
                        Attack mewtwoSpecial1 = game.battle.attacks.get("Mewtwo_Special1");
                        mewtwoSpecial1.damage = gen2CalcDamage(game.battle.oppPokemon, mewtwoSpecial1, game.player.currPokemon);
                        nextAction = new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "A wave of psychic power unleashes!", (String) null, true, false, getAttackAction(game, mewtwoSpecial1, !isFriendly, depleteHealth(game, false, mewtwoSpecial1.damage, true, new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, nextAction))))))));
                        SpecialBattleMewtwo.specialAttackCounter = 0;
                    }
                }
                if (RegigigasBattle.Draw.class.isInstance(game.battle.drawAction) && !isFriendly) {
                    RegigigasBattle.Draw.specialAttackCounter++;
                    if (RegigigasBattle.Draw.specialAttackCounter >= 3) {
                        Attack regigigasSpecial = game.battle.attacks.get("Regigigas_Special1");
                        regigigasSpecial.damage = gen2CalcDamage(game.battle.oppPokemon, regigigasSpecial, game.player.currPokemon);
                        String effectiveness2 = "neutral_effective";
                        float multiplier = 1.0f;
                        String prevType = "";
                        Iterator<String> it = game.player.currPokemon.types.iterator();
                        while (it.hasNext()) {
                            String type = it.next();
                            if (!type.equals(prevType)) {
                                prevType = type;
                                multiplier *= game.battle.gen2TypeEffectiveness.get(attack.type).get(type.toLowerCase(Locale.ROOT)).floatValue();
                            }
                        }
                        if (multiplier > 1.0f) {
                            effectiveness2 = "super_effective";
                        } else if (multiplier == 1.0f) {
                            effectiveness2 = "neutral_effective";
                        } else if (multiplier > 0.0f) {
                            effectiveness2 = "not_very_effective";
                        }
                        nextAction = new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "The ground is shaking violently!", (String) null, (Action) null, new RegigigasBattle.SpecialAttack(new LoadAndPlayAnimation(game, effectiveness2, game.player.currPokemon, depleteHealth(game, false, regigigasSpecial.damage, true, new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, nextAction)))))))));
                        RegigigasBattle.Draw.specialAttackCounter = 0;
                    }
                }
                if (isFriendly) {
                    friendlyPokemon = game.player.currPokemon;
                    enemyPokemon = game.battle.oppPokemon;
                } else {
                    friendlyPokemon = game.battle.oppPokemon;
                    enemyPokemon = game.player.currPokemon;
                }
                Action attackAction = new Action(new Object[0]) { // from class: com.corona.game.Battle.1
                    @Override // com.corona.game.Action
                    public String getCamera() {
                        return "gui";
                    }
                };
                String enemy = isFriendly ? "" : "Enemy ";
                if (friendlyPokemon.disabledCounter > 0) {
                    friendlyPokemon.disabledCounter--;
                }
                if (friendlyPokemon.disabledCounter <= 0 && friendlyPokemon.disabledIndex != -1) {
                    attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + friendlyPokemon.attacks[friendlyPokemon.disabledIndex] + " is no longer disabled!", (String) null, true, false, (Action) null))));
                    friendlyPokemon.disabledIndex = -1;
                }
                if (friendlyPokemon.flinched) {
                    return new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " flinched!", (String) null, true, true, (Action) new WaitFrames(game, 10, nextAction))));
                }
                if (isFriendly) {
                    previousAttackIndex = DrawBattle.prevFriendlyAttackIndex;
                } else {
                    previousAttackIndex = DrawBattle.prevEnemyAttackIndex;
                }
                String previousAttack = "";
                if (previousAttackIndex >= 0) {
                    previousAttack = friendlyPokemon.attacks[previousAttackIndex];
                }
                if ("hyper beam".equals(previousAttack)) {
                    if (isFriendly) {
                        DrawBattle.prevFriendlyAttackIndex = -1;
                    } else {
                        DrawBattle.prevEnemyAttackIndex = -1;
                    }
                    return new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " must recharge!", (String) null, true, true, (Action) new WaitFrames(game, 10, nextAction))));
                }
                int attackIndex = -1;
                int i = 0;
                while (true) {
                    if (i >= friendlyPokemon.attacks.length) {
                        break;
                    } else if (friendlyPokemon.attacks[i] != null && friendlyPokemon.attacks[i].equals(attack.name)) {
                        attackIndex = i;
                        break;
                    } else {
                        i++;
                    }
                }
                if (attackIndex <= -1 || attackIndex != friendlyPokemon.disabledIndex) {
                    if (friendlyPokemon.status != null) {
                        if (friendlyPokemon.status.equals("sleep")) {
                            friendlyPokemon.statusCounter--;
                            if (friendlyPokemon.statusCounter > 0) {
                                return new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " is fast asleep!", (String) null, true, true, (Action) new WaitFrames(game, 23, new LoadAndPlayAnimation(game, "status_sleep", friendlyPokemon, nextAction)))));
                            }
                            attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " woke up!", (String) null, true, true, (Action) new SetField(friendlyPokemon, "status", null, null)))));
                        } else if (friendlyPokemon.status.equals("paralyze")) {
                            if (game.map.rand.nextInt(256) < 128) {
                                return new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " is fully paralyzed!", (String) null, true, true, nextAction)));
                            }
                        } else if (friendlyPokemon.status.equals("freeze")) {
                            if (game.map.rand.nextInt(256) >= 51) {
                                return new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " is frozen solid!", (String) null, true, true, nextAction)));
                            }
                            attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " thawed out!", (String) null, true, true, (Action) new SetField(friendlyPokemon, "status", null, null)))));
                        }
                    }
                    ArrayList<String> removeStatus = new ArrayList<>();
                    boolean returnAction = false;
                    Collections.sort(friendlyPokemon.volatileStatus);
                    int i2 = 0;
                    while (true) {
                        if (i2 >= friendlyPokemon.volatileStatus.size()) {
                            break;
                        }
                        String status = friendlyPokemon.volatileStatus.get(i2);
                        if (status.equals("confuse")) {
                            friendlyPokemon.volatileStatusCounter.put(status, Integer.valueOf(friendlyPokemon.volatileStatusCounter.get(status).intValue() - 1));
                            if (friendlyPokemon.volatileStatusCounter.get(status).intValue() > 0) {
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " is confused!", (String) null, true, true, (Action) new WaitFrames(game, 24, new LoadAndPlayAnimation(game, "status_confuse", friendlyPokemon, null))))));
                                if (game.map.rand.nextInt(256) < 128) {
                                    Attack confustionAtk = game.battle.attacks.get("confusion_hit");
                                    confustionAtk.damage = gen2CalcDamage(friendlyPokemon, confustionAtk, friendlyPokemon);
                                    attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "It hurt itself in confusion!", (String) null, true, false, (Action) new LoadAndPlayAnimation(game, "struggle", friendlyPokemon, depleteHealth(game, !isFriendly, confustionAtk.damage, new WaitFrames(game, 13, nextAction)))))));
                                    returnAction = true;
                                }
                            } else {
                                removeStatus.add(status);
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " snapped out of confusion!", (String) null, true, true, (Action) null))));
                            }
                            i2++;
                        } else {
                            if (status.equals("attract")) {
                                String enemy2 = !isFriendly ? "" : "enemy ";
                                attackAction.append(new DisplayText.Clear(game, null));
                                attackAction.append(new WaitFrames(game, 3, null));
                                attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " is in love with " + enemy2 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, true, true, (Action) null));
                                attackAction.append(new WaitFrames(game, 24, null));
                                attackAction.append(new LoadAndPlayAnimation(game, "love", enemyPokemon, null));
                                if (game.map.rand.nextInt(256) < 128) {
                                    attackAction.append(new DisplayText.Clear(game, null));
                                    attackAction.append(new WaitFrames(game, 3, null));
                                    attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' infatuation kept it from attacking!", (String) null, true, true, (Action) null));
                                    returnAction = true;
                                    break;
                                }
                            } else {
                                continue;
                            }
                            i2++;
                        }
                    }
                    for (int i3 = 0; i3 < removeStatus.size(); i3++) {
                        int j = 0;
                        while (true) {
                            if (j >= friendlyPokemon.volatileStatus.size()) {
                                break;
                            } else if (friendlyPokemon.volatileStatus.get(j) == removeStatus.get(i3)) {
                                friendlyPokemon.volatileStatus.remove(j);
                                break;
                            } else {
                                j++;
                            }
                        }
                    }
                    if (returnAction) {
                        return attackAction;
                    }
                    int accuracyStage = friendlyPokemon.statStages.get("accuracy").intValue();
                    int accuracy2 = (int) (((float) ((attack.accuracy * 255) / 100)) * (((float) Math.max(3, 3 + accuracyStage)) / ((float) Math.max(3, 3 - accuracyStage))));
                    if (accuracy2 < 1) {
                        accuracy2 = 1;
                    }
                    int evasionStage = enemyPokemon.statStages.get("evasion").intValue();
                    int accuracy3 = (int) (((float) accuracy2) * (((float) Math.max(3, 3 - evasionStage)) / ((float) Math.max(3, 3 + evasionStage))));
                    if (accuracy3 < 1) {
                        accuracy3 = 1;
                    }
                    if (accuracy3 > 255) {
                        accuracy3 = 255;
                    }
                    boolean attackMisses = accuracy3 < 255 && game.map.rand.nextInt(256) >= accuracy3;
                    boolean targetAirborne = isFriendly ? game.battle.oppAirborne : game.battle.playerAirborne;
                    boolean userAirborne = isFriendly ? game.battle.playerAirborne : game.battle.oppAirborne;
                    boolean targetUnderground = isFriendly ? game.battle.oppUnderground : game.battle.playerUnderground;
                    boolean userUnderground = isFriendly ? game.battle.playerUnderground : game.battle.oppUnderground;
                    if (targetAirborne && !attack.name.equals("gust") && !attack.name.equals("thunder") && !attack.name.equals("twister") && !attack.name.equals("whirlwind")) {
                        attackMisses = true;
                    }
                    if (targetUnderground && !attack.name.equals("earthquake") && !attack.name.equals("magnitude") && !attack.name.equals("fissure")) {
                        attackMisses = true;
                    }
                    if (attack.effect.equals("EFFECT_ALWAYS_HIT")) {
                        if (game.battle.generation != Pokemon.Generation.CRYSTAL) {
                            attackMisses = false;
                        } else if (!targetAirborne && !targetUnderground) {
                            attackMisses = false;
                        }
                    }
                    if (attack.name.equals("thunder") && game.battle.weather != null && game.battle.weather.equals("rain dance")) {
                        attackMisses = false;
                        if (targetUnderground) {
                            attackMisses = true;
                        }
                    }
                    boolean setup = false;
                    if (attack.effect.equals("EFFECT_FLY")) {
                        if ((attack.name.equals("dig") && !userUnderground) || (attack.name.equals("fly") && !userAirborne)) {
                            attackMisses = false;
                            setup = true;
                        }
                    } else if (attack.effect.equals("EFFECT_SOLARBEAM")) {
                        boolean sunnyDay = false;
                        if (game.battle.weather != null && game.battle.weather.equals("sunny day")) {
                            sunnyDay = true;
                        }
                        if (!sunnyDay) {
                            String prevAttack = null;
                            int lockedMove = game.battle.oppLockedMove;
                            int prevAttackIndex = DrawBattle.prevEnemyAttackIndex;
                            if (prevAttackIndex >= 0) {
                                prevAttack = game.battle.oppPokemon.attacks[prevAttackIndex];
                            }
                            if (isFriendly) {
                                prevAttack = null;
                                prevAttackIndex = DrawBattle.prevFriendlyAttackIndex;
                                if (prevAttackIndex >= 0) {
                                    prevAttack = game.player.currPokemon.attacks[prevAttackIndex];
                                }
                                lockedMove = game.battle.playerLockedMove;
                            }
                            boolean setupCompleted = false;
                            if (prevAttack != null && prevAttack.equals(attack.name) && lockedMove == prevAttackIndex) {
                                setupCompleted = true;
                            }
                            if (!setupCompleted) {
                                attackMisses = false;
                                setup = true;
                            }
                        }
                    } else if (attack.effect.equals("EFFECT_RAZOR_WIND") || attack.effect.equals("EFFECT_SKY_ATTACK")) {
                        String prevAttack2 = null;
                        int lockedMove2 = game.battle.oppLockedMove;
                        int prevAttackIndex2 = DrawBattle.prevEnemyAttackIndex;
                        if (prevAttackIndex2 >= 0) {
                            prevAttack2 = game.battle.oppPokemon.attacks[prevAttackIndex2];
                        }
                        if (isFriendly) {
                            prevAttack2 = null;
                            prevAttackIndex2 = DrawBattle.prevFriendlyAttackIndex;
                            if (prevAttackIndex2 >= 0) {
                                prevAttack2 = game.player.currPokemon.attacks[prevAttackIndex2];
                            }
                            lockedMove2 = game.battle.playerLockedMove;
                        }
                        boolean setupCompleted2 = false;
                        if (prevAttack2 != null && prevAttack2.equals(attack.name) && lockedMove2 == prevAttackIndex2) {
                            setupCompleted2 = true;
                        }
                        if (!setupCompleted2) {
                            attackMisses = false;
                            setup = true;
                        }
                    }
                    String usedText = enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " used " + attack.name.toUpperCase(Locale.ROOT) + "!";
                    if (setup) {
                        usedText = " ";
                    }
                    attackAction.append(new DisplayText.Clear(game, null));
                    attackAction.append(new WaitFrames(game, 3, null));
                    attackAction.append(new DisplayText(game, usedText, (String) null, true, false, (Action) null));
                    boolean presentHealed = false;
                    if (attack.effect.equals("EFFECT_PRESENT")) {
                        int randomNum = Game.rand.nextInt(100);
                        if (randomNum < 40) {
                            attack.power = 40;
                        } else if (randomNum < 70) {
                            attack.power = 80;
                        } else if (randomNum < 80) {
                            attack.power = 120;
                        } else {
                            attack.power = 0;
                            presentHealed = true;
                        }
                    }
                    if (attack.power != 0) {
                        if (attackMisses) {
                            int lockedMove3 = game.battle.oppLockedMove;
                            if (isFriendly) {
                                lockedMove3 = game.battle.playerLockedMove;
                            }
                            boolean resetHidden = false;
                            if (lockedMove3 != -1) {
                                if (friendlyPokemon.attacks[lockedMove3].equals("dig") || friendlyPokemon.attacks[lockedMove3].equals("fly")) {
                                    resetHidden = true;
                                }
                                if (isFriendly) {
                                    game.battle.playerLockedMove = -1;
                                    if (friendlyPokemon.attacks[lockedMove3].equals("dig")) {
                                        game.battle.playerUnderground = false;
                                    } else if (friendlyPokemon.attacks[lockedMove3].equals("fly")) {
                                        game.battle.playerAirborne = false;
                                    }
                                } else {
                                    game.battle.oppLockedMove = -1;
                                    if (friendlyPokemon.attacks[lockedMove3].equals("dig")) {
                                        game.battle.oppUnderground = false;
                                    } else if (friendlyPokemon.attacks[lockedMove3].equals("fly")) {
                                        game.battle.oppAirborne = false;
                                    }
                                }
                            }
                            attackAction.append(new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "The attack missed!", (String) null, true, true, (Action) null)))));
                            if (resetHidden) {
                                String field = "hideOppPokemon";
                                if (isFriendly) {
                                    field = "hideOwnPokemon";
                                }
                                attackAction.append(new SetField(game.battle.drawAction, field, false, null));
                            }
                            attackAction.append(nextAction);
                            return attackAction;
                        }
                        if (attack.effect.equals("EFFECT_ROLLOUT")) {
                            if (isFriendly) {
                                if (game.battle.playerLockedMove == -1) {
                                    game.battle.playerLockedMove = attackIndex;
                                    game.battle.playerLockedMoveCounter = 5;
                                }
                            } else if (game.battle.oppLockedMove == -1) {
                                game.battle.oppLockedMove = attackIndex;
                                game.battle.oppLockedMoveCounter = 5;
                            }
                        }
                        String finalAttackName = attack.name;
                        if (setup) {
                            String text4 = null;
                            if (isFriendly) {
                                game.battle.playerLockedMove = attackIndex;
                                game.battle.playerLockedMoveCounter = 2;
                            } else {
                                game.battle.oppLockedMove = attackIndex;
                                game.battle.oppLockedMoveCounter = 2;
                            }
                            if (attack.name.equals("dig")) {
                                text4 = enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " dug a hole!";
                                if (isFriendly) {
                                    game.battle.playerUnderground = true;
                                } else {
                                    game.battle.oppUnderground = true;
                                }
                            } else if (attack.name.equals("fly")) {
                                text4 = enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " flew up high!";
                                if (isFriendly) {
                                    game.battle.playerAirborne = true;
                                } else {
                                    game.battle.oppAirborne = true;
                                }
                            } else if (attack.name.equals("solarbeam")) {
                                text4 = enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " took in sunlight!";
                            } else if (attack.name.equals("razor wind")) {
                                text4 = enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " made a whirlwind!";
                            } else if (attack.name.equals("sky attack")) {
                                text4 = enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " is glowing!";
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, finalAttackName + " setup", enemyPokemon, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, text4, (String) null, (Action) null, (Action) null));
                        } else {
                            attack.isCrit = gen2DetermineCrit(friendlyPokemon, attack);
                            attack.damage = gen2CalcDamage(friendlyPokemon, attack, enemyPokemon);
                            float multiplier2 = 1.0f;
                            String prevType2 = "";
                            Iterator<String> it2 = enemyPokemon.types.iterator();
                            while (it2.hasNext()) {
                                String type2 = it2.next();
                                if (!type2.equals(prevType2)) {
                                    prevType2 = type2;
                                    multiplier2 *= game.battle.gen2TypeEffectiveness.get(attack.type).get(type2.toLowerCase(Locale.ROOT)).floatValue();
                                }
                            }
                            if ((attack.effect.equals("EFFECT_LEVEL_DAMAGE") || attack.effect.equals("EFFECT_STATIC_DAMAGE")) && multiplier2 != 0.0f) {
                                multiplier2 = 1.0f;
                            }
                            String text_string = "";
                            if (multiplier2 > 1.0f) {
                                effectiveness = "super_effective";
                                text_string = "It' super- effective!";
                            } else if (multiplier2 == 1.0f) {
                                effectiveness = "neutral_effective";
                            } else if (multiplier2 > 0.0f) {
                                effectiveness = "not_very_effective";
                                text_string = "It' not very effective...";
                            } else {
                                int lockedMove4 = game.battle.oppLockedMove;
                                if (isFriendly) {
                                    lockedMove4 = game.battle.playerLockedMove;
                                }
                                boolean resetHidden2 = false;
                                if (lockedMove4 != -1) {
                                    if (friendlyPokemon.attacks[lockedMove4].equals("dig") || friendlyPokemon.attacks[lockedMove4].equals("fly")) {
                                        resetHidden2 = true;
                                    }
                                    if (isFriendly) {
                                        game.battle.playerLockedMove = -1;
                                        if (friendlyPokemon.attacks[lockedMove4].equals("dig")) {
                                            game.battle.playerUnderground = false;
                                        } else if (friendlyPokemon.attacks[lockedMove4].equals("fly")) {
                                            game.battle.playerAirborne = false;
                                        }
                                    } else {
                                        game.battle.oppLockedMove = -1;
                                        if (friendlyPokemon.attacks[lockedMove4].equals("dig")) {
                                            game.battle.oppUnderground = false;
                                        } else if (friendlyPokemon.attacks[lockedMove4].equals("fly")) {
                                            game.battle.oppAirborne = false;
                                        }
                                    }
                                }
                                attackAction.append(new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "It doesnì affect " + enemy + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, true, true, (Action) null)))));
                                if (resetHidden2) {
                                    String field2 = "hideOppPokemon";
                                    if (isFriendly) {
                                        field2 = "hideOwnPokemon";
                                    }
                                    attackAction.append(new SetField(game.battle.drawAction, field2, false, null));
                                }
                                attackAction.append(nextAction);
                                return attackAction;
                            }
                            if (attack.effect.equals("EFFECT_FALSE_SWIPE") && attack.damage >= enemyPokemon.currentStats.get("hp").intValue()) {
                                attack.damage = enemyPokemon.currentStats.get("hp").intValue() - 1;
                                if (attack.damage < 1) {
                                    attack.damage = 0;
                                }
                            }
                            if (attack.effect.equals("EFFECT_MULTI_HIT") || attack.effect.equals("EFFECT_DOUBLE_HIT")) {
                                int numHits = 1;
                                if (attack.effect.equals("EFFECT_MULTI_HIT")) {
                                    int numHits2 = Game.rand.nextInt(256);
                                    if (numHits2 < 96) {
                                        numHits = 1;
                                    } else if (numHits2 < 192) {
                                        numHits = 2;
                                    } else if (numHits2 < 224) {
                                        numHits = 3;
                                    } else {
                                        numHits = 4;
                                    }
                                }
                                ArrayList<String> leftRightAnims = new ArrayList<>();
                                leftRightAnims.add("doubleslap");
                                leftRightAnims.add("double kick");
                                leftRightAnims.add("fury swipes");
                                boolean usesLeftRightAnim = false;
                                if (leftRightAnims.contains(attack.name)) {
                                    usesLeftRightAnim = true;
                                }
                                for (int i4 = 0; i4 < numHits; i4++) {
                                    String attackName = attack.name;
                                    if (usesLeftRightAnim) {
                                        if ((i4 & 1) == 0) {
                                            attackName = attackName + " left";
                                            finalAttackName = attack.name + " right";
                                        } else {
                                            attackName = attackName + " right";
                                            finalAttackName = attack.name + " left";
                                        }
                                    }
                                    attackAction.append(new LoadAndPlayAnimation(game, attackName, enemyPokemon, null));
                                    attackAction.append(depleteHealth(game, isFriendly, attack.damage, false, new WaitFrames(game, 13, new WaitFrames(game, 30, null))));
                                    if (attack.isCrit) {
                                        attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "Critical hit!", (String) null, (Action) null, (Action) null))));
                                    }
                                    attackAction.append(detectFaint(game, isFriendly, null));
                                    attack.isCrit = gen2DetermineCrit(friendlyPokemon, attack);
                                    attack.damage = gen2CalcDamage(friendlyPokemon, attack, enemyPokemon);
                                }
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, finalAttackName, enemyPokemon, null));
                            attackAction.append(new LoadAndPlayAnimation(game, effectiveness, enemyPokemon, depleteHealth(game, isFriendly, attack.damage, false, new WaitFrames(game, 13, null))));
                            if (attack.isCrit) {
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "Critical hit!", (String) null, (Action) null, (Action) null))));
                            }
                            if (!effectiveness.equals("neutral_effective")) {
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, text_string, (String) null, true, true, (Action) null))));
                            }
                            if (attack.effect.contains("FLINCH_HIT") || attack.effect.contains("EFFECT_TWISTER")) {
                                int accuracy4 = (attack.effectChance * 255) / 100;
                                attackMisses = accuracy4 < 255 && game.map.rand.nextInt(256) >= accuracy4;
                                if (!attackMisses) {
                                    enemyPokemon.flinched = true;
                                }
                            }
                            if (attack.effect.equals("EFFECT_FLY")) {
                                if (attack.name.equals("dig")) {
                                    if (isFriendly) {
                                        game.battle.playerUnderground = false;
                                    } else {
                                        game.battle.oppUnderground = false;
                                    }
                                } else if (attack.name.equals("fly")) {
                                    if (isFriendly) {
                                        game.battle.playerAirborne = false;
                                    } else {
                                        game.battle.oppAirborne = false;
                                    }
                                }
                            }
                        }
                    }
                    if (isFriendly) {
                        DrawBattle.prevFriendlyAttackIndex = attackIndex;
                    } else {
                        DrawBattle.prevEnemyAttackIndex = attackIndex;
                    }
                    if (attack.effect.equals("EFFECT_RECOIL_HIT") || attack.name.equals("flare blitz")) {
                        int recoilDamage = attack.damage / 4;
                        if (attack.name.equals("brave bird") || attack.name.equals("flare blitz") || attack.name.equals("volt tackle") || attack.name.equals("wood hammer")) {
                            recoilDamage = attack.damage / 3;
                        } else if (attack.name.equals("head smash") || attack.name.equals("light of ruin")) {
                            recoilDamage = attack.damage / 2;
                        }
                        attackAction.append(depleteHealth(game, !isFriendly, recoilDamage, false, new WaitFrames(game, 13, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' hit with recoil!", (String) null, (Action) null, (Action) null))))));
                    }
                    if (attack.effect.equals("EFFECT_HEAL") || attack.effect.equals("EFFECT_SYNTHESIS") || attack.effect.equals("EFFECT_LEECH_HIT") || attack.effect.equals("EFFECT_DRAINING_KISS") || attack.effect.equals("EFFECT_MORNING_SUN") || attack.effect.equals("EFFECT_MOONLIGHT") || presentHealed) {
                        int amount = friendlyPokemon.maxStats.get("hp").intValue() / 2;
                        if (attack.effect.equals("EFFECT_SYNTHESIS")) {
                            amount = friendlyPokemon.maxStats.get("hp").intValue() / 4;
                            if (game.map.timeOfDay.equals("day")) {
                                amount *= 2;
                            }
                        } else if (attack.effect.equals("EFFECT_LEECH_HIT")) {
                            amount = attack.damage / 2;
                            if (amount < 1) {
                                amount = 1;
                            }
                            int enemyHp = enemyPokemon.currentStats.get("hp").intValue();
                            if (amount > enemyHp) {
                                amount = enemyHp;
                            }
                        } else if (attack.effect.equals("EFFECT_DRAINING_KISS")) {
                            amount = (3 * attack.damage) / 4;
                            if (amount < 1) {
                                amount = 1;
                            }
                            int enemyHp2 = enemyPokemon.currentStats.get("hp").intValue();
                            if (amount > enemyHp2) {
                                amount = enemyHp2;
                            }
                        } else if (attack.effect.equals("EFFECT_MORNING_SUN")) {
                            amount = friendlyPokemon.maxStats.get("hp").intValue() / 4;
                            if (game.map.timeOfDay.equals("day")) {
                                amount *= 2;
                            }
                        } else if (attack.effect.equals("EFFECT_MOONLIGHT")) {
                            amount = friendlyPokemon.maxStats.get("hp").intValue() / 4;
                            if (game.map.timeOfDay.equals("night")) {
                                amount *= 2;
                            }
                        } else if (attack.effect.equals("EFFECT_PRESENT")) {
                            amount = enemyPokemon.maxStats.get("hp").intValue() / 4;
                            isFriendly = !isFriendly;
                            friendlyPokemon = enemyPokemon;
                            enemyPokemon = friendlyPokemon;
                        }
                        enemy = isFriendly ? "" : "Enemy ";
                        if (friendlyPokemon.currentStats.get("hp").intValue() >= friendlyPokemon.maxStats.get("hp").intValue()) {
                            attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' HP is full!", (String) null, false, true, (Action) null))));
                        } else {
                            if (!attack.effect.contains("HIT")) {
                                attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            }
                            attackAction.append(new RestoreHealth(friendlyPokemon, -amount, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " regained health!", (String) null, false, true, (Action) null)))));
                        }
                    }
                    if (attack.effect.equals("EFFECT_SELFDESTRUCT")) {
                        friendlyPokemon.currentStats.put("hp", 0);
                    }
                    if (attack.effect.equals("EFFECT_CURSE")) {
                        if (!friendlyPokemon.types.contains("GHOST")) {
                            boolean attackWorked = friendlyPokemon.gen2ApplyStatStage("attack", 1);
                            boolean defenseWorked = friendlyPokemon.gen2ApplyStatStage("defense", 1);
                            if (attackWorked || defenseWorked) {
                                attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, null)));
                                if (friendlyPokemon.gen2ApplyStatStage("speed", -1)) {
                                    text = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + "speed".toUpperCase(Locale.ROOT) + " fell!";
                                } else {
                                    text = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + "speed".toUpperCase(Locale.ROOT) + " wonì go any " + (-1 > 0 ? "higher!" : "lower!");
                                }
                                attackAction.append(new DisplayText(game, text, (String) null, (Action) null, (Action) null));
                                if (attackWorked) {
                                    text2 = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + "attack".toUpperCase(Locale.ROOT) + " went up!";
                                } else {
                                    text2 = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + "attack".toUpperCase(Locale.ROOT) + " wonì go any " + (1 > 0 ? "higher!" : "lower!");
                                }
                                attackAction.append(new DisplayText(game, text2, (String) null, (Action) null, (Action) null));
                                if (defenseWorked) {
                                    text3 = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + "defense".toUpperCase(Locale.ROOT) + " went up!";
                                } else {
                                    text3 = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + "defense".toUpperCase(Locale.ROOT) + " wonì go any " + (1 > 0 ? "higher!" : "lower!");
                                }
                                attackAction.append(new DisplayText(game, text3, (String) null, (Action) null, (Action) null));
                            } else {
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null))));
                            }
                        } else {
                            boolean alreadyHasStatus = false;
                            int i5 = 0;
                            while (true) {
                                if (i5 >= enemyPokemon.volatileStatus.size()) {
                                    break;
                                } else if (enemyPokemon.volatileStatus.get(i5).equals("curse")) {
                                    alreadyHasStatus = true;
                                    break;
                                } else {
                                    i5++;
                                }
                            }
                            if (alreadyHasStatus) {
                                attackAction.append(new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null)))));
                            } else {
                                enemyPokemon.volatileStatus.add("curse");
                                int selfDamage = friendlyPokemon.maxStats.get("hp").intValue() / 2;
                                attackAction.append(new LoadAndPlayAnimation(game, attack.name + "_ghost", enemyPokemon, null));
                                attackAction.append(depleteHealth(game, !isFriendly, selfDamage, false, null));
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, null)));
                                attackAction.append(new DisplayText(game, friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " cut its own hp and", (String) null, (Action) null, (Action) null));
                                attackAction.append(new DisplayText(game, "put a CURSE on " + enemy + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, (Action) null, (Action) null));
                            }
                        }
                    }
                    if (attack.effect.equals("EFFECT_FORCE_SWITCH")) {
                        boolean failed = false;
                        if (friendlyPokemon.level < enemyPokemon.level && Game.rand.nextInt(100) <= ((int) Math.ceil((double) ((((float) (enemyPokemon.level / 4)) / ((float) ((enemyPokemon.level + friendlyPokemon.level) + 1))) * 100.0f)))) {
                            failed = true;
                        }
                        if (failed) {
                            attackAction.append(new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null)))));
                        } else {
                            String drivenAwayText = enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " fled in fear!";
                            if (attack.name.contains("whirlwind")) {
                                drivenAwayText = enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " was blown away!";
                            }
                            if (enemyPokemon == game.battle.oppPokemon) {
                                drivenAwayText = "Enemy " + drivenAwayText;
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DrivenAway(enemyPokemon, drivenAwayText));
                            return attackAction;
                        }
                    }
                    if (attack.effect.equals("EFFECT_SPLASH")) {
                        attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But nothing happened.", (String) null, false, true, (Action) null))))));
                    }
                    if (attack.effect.equals("EFFECT_TELEPORT")) {
                        boolean failed2 = false;
                        if (friendlyPokemon.level < enemyPokemon.level && Game.rand.nextInt(100) <= ((int) Math.ceil((double) ((((float) (enemyPokemon.level / 4)) / ((float) ((enemyPokemon.level + friendlyPokemon.level) + 1))) * 100.0f)))) {
                            failed2 = true;
                        }
                        if (friendlyPokemon.cantEscapeBy != null) {
                            failed2 = true;
                        }
                        if (failed2) {
                            attackAction.append(new WaitFrames(game, 30, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null));
                        } else {
                            String teleportedAwayText = friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " fled from battle!";
                            if (friendlyPokemon == game.battle.oppPokemon) {
                                teleportedAwayText = "Enemy " + teleportedAwayText;
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DrivenAway(friendlyPokemon, teleportedAwayText));
                            return attackAction;
                        }
                    }
                    if (attack.effect.equals("EFFECT_MEAN_LOOK")) {
                        if (enemyPokemon.cantEscapeBy != null) {
                            attackAction.append(new WaitFrames(game, 30, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null));
                        } else {
                            String escapeText = enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " canì escape now!";
                            if (enemyPokemon == game.battle.oppPokemon) {
                                escapeText = "Enemy " + escapeText;
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, escapeText, (String) null, false, true, (Action) null));
                            enemyPokemon.cantEscapeBy = friendlyPokemon;
                        }
                    }
                    if (attack.effect.equals("EFFECT_METRONOME")) {
                        String[] cantSelect = {"counter", "destiny bond", "detect", "endure", "mimic", "mirror coat", "protect", "sketch", "sleep talk", "struggle", "thief"};
                        String selectedAttack = null;
                        while (selectedAttack == null) {
                            String randomAttack = Pokemon.attacksImplemented.get(Game.rand.nextInt(Pokemon.attacksImplemented.size() - 1));
                            if (!Arrays.asList(cantSelect).contains(randomAttack) && !Arrays.asList(friendlyPokemon.attacks).contains(randomAttack)) {
                                selectedAttack = randomAttack;
                            }
                        }
                        attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                        attackAction.append(new DisplayText.Clear(game, null));
                        attackAction.append(new WaitFrames(game, 3, null));
                        attackAction.append(getAttackAction(game, game.battle.attacks.get(selectedAttack), isFriendly, null));
                        return attackAction;
                    }
                    if (attack.effect.equals("EFFECT_REFLECT") || attack.effect.equals("EFFECT_LIGHT_SCREEN")) {
                        boolean failed3 = false;
                        if (isFriendly && ((attack.effect.equals("EFFECT_REFLECT") && game.battle.playerReflectDown) || (attack.effect.equals("EFFECT_LIGHT_SCREEN") && game.battle.playerLightScreenDown))) {
                            failed3 = true;
                        } else if (!isFriendly && ((attack.effect.equals("EFFECT_REFLECT") && game.battle.oppReflectDown) || (attack.effect.equals("EFFECT_LIGHT_SCREEN") && game.battle.oppLightScreenDown))) {
                            failed3 = true;
                        }
                        if (failed3) {
                            attackAction.append(new WaitFrames(game, 30, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null));
                        } else {
                            String stat = "DEFENSE";
                            if (!attack.effect.equals("EFFECT_REFLECT")) {
                                stat = "SPCL.DEF";
                                if (isFriendly) {
                                    game.battle.playerLightScreenDown = true;
                                    game.battle.playerLightScreenCounter = 5;
                                } else {
                                    game.battle.oppLightScreenDown = true;
                                    game.battle.oppLightScreenCounter = 5;
                                }
                            } else if (isFriendly) {
                                game.battle.playerReflectDown = true;
                                game.battle.playerReflectCounter = 5;
                            } else {
                                game.battle.oppReflectDown = true;
                                game.battle.oppReflectCounter = 5;
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + stat + " rose!", (String) null, false, true, (Action) null));
                        }
                    }
                    if (friendlyPokemon.status != null && friendlyPokemon.status.equals("freeze") && attack.effect.equals("EFFECT_SACRED_FIRE")) {
                        attackAction.append(new DisplayText.Clear(game, null));
                        attackAction.append(new WaitFrames(game, 3, null));
                        attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " thawed out!", (String) null, true, true, (Action) null));
                        attackAction.append(new SetField(friendlyPokemon, "status", null, null));
                    }
                    if (attack.effect.equals("EFFECT_RAIN_DANCE") || attack.effect.equals("EFFECT_SUNNY_DAY") || attack.effect.equals("EFFECT_SANDSTORM")) {
                        boolean failed4 = false;
                        if (game.battle.weather != null && game.battle.weather.equals("sandstorm") && attack.effect.equals("EFFECT_SANDSTORM")) {
                            failed4 = true;
                        }
                        if (failed4) {
                            attackAction.append(new WaitFrames(game, 30, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null));
                        } else {
                            String text5 = "A downpour started!";
                            if (attack.effect.equals("EFFECT_SUNNY_DAY")) {
                                text5 = "The sunlight got bright!";
                            } else if (attack.effect.equals("EFFECT_SANDSTORM")) {
                                text5 = "A SANDSTORM brewed!";
                            }
                            game.battle.weather = attack.name;
                            game.battle.weatherCounter = 5;
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, text5, (String) null, false, true, (Action) null));
                        }
                    }
                    if (attack.effect.equals("EFFECT_SAFEGUARD")) {
                        if (!(isFriendly ? game.battle.playerSafeguardDown : game.battle.oppSafeguardDown)) {
                            if (isFriendly) {
                                game.battle.playerSafeguardDown = true;
                                game.battle.playerSafeguardCounter = 5;
                            } else {
                                game.battle.oppSafeguardDown = true;
                                game.battle.oppSafeguardCounter = 5;
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' covered by a veil!", (String) null, false, true, (Action) null));
                        } else if (attack.power != 0) {
                            return attackAction;
                        } else {
                            attackAction.append(new WaitFrames(game, 30, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, enemy + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " is protected by SAFEGUARD!", (String) null, true, true, nextAction));
                            return attackAction;
                        }
                    }
                    if (attack.effect.equals("EFFECT_SPIKES")) {
                        boolean failed5 = false;
                        if ((isFriendly && game.battle.oppSpikesDown) || (!isFriendly && game.battle.playerSpikesDown)) {
                            failed5 = true;
                        }
                        if (failed5) {
                            attackAction.append(new WaitFrames(game, 30, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null));
                        } else {
                            String enemy22 = "";
                            if (isFriendly) {
                                game.battle.oppSpikesDown = true;
                                enemy22 = "enemy ";
                            } else {
                                game.battle.playerSpikesDown = true;
                            }
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, "SPIKES scattered all around " + enemy22 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " !", (String) null, false, true, (Action) null));
                        }
                    }
                    if (attack.effect.equals("EFFECT_RAPID_SPIN")) {
                        boolean removeSpikes = false;
                        if (isFriendly && game.battle.playerSpikesDown) {
                            removeSpikes = true;
                            game.battle.playerSpikesDown = false;
                        } else if (!isFriendly && game.battle.oppSpikesDown) {
                            removeSpikes = true;
                            game.battle.oppSpikesDown = false;
                        }
                        if (removeSpikes) {
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " blew away SPIKES!", (String) null, false, true, (Action) null));
                        }
                        boolean removeTrap = false;
                        String enemy23 = "";
                        if (isFriendly && game.player.currPokemon.trappedBy != null) {
                            removeTrap = true;
                            enemy23 = "enemy ";
                            game.player.currPokemon.trappedBy = null;
                            game.player.currPokemon.trapCounter = 0;
                        } else if (!isFriendly && game.battle.oppPokemon.trappedBy != null) {
                            removeTrap = true;
                            game.battle.oppPokemon.trappedBy = null;
                            game.battle.oppPokemon.trapCounter = 0;
                        }
                        if (removeTrap) {
                            attackAction.append(new DisplayText.Clear(game, null));
                            attackAction.append(new WaitFrames(game, 3, null));
                            attackAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " was released by " + enemy23 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, false, true, (Action) null));
                        }
                    }
                    attackAction.append(detectFaint(game, isFriendly, false, null));
                    attackAction.append(detectFaint(game, !isFriendly, false, null));
                    attackAction.append(new CheckWhitedOut(null));
                    attackAction.append(new CheckEndOfBattle(null));
                    attackAction.append(new CheckShouldSwitch(null));
                    String stat2 = null;
                    if (attack.effect.contains("EFFECT_ATTACK")) {
                        stat2 = "attack";
                    } else if (attack.effect.contains("EFFECT_DEFENSE")) {
                        stat2 = "defense";
                    } else if (attack.effect.contains("EFFECT_SPEED")) {
                        stat2 = "speed";
                    } else if (attack.effect.contains("EFFECT_SP_ATK")) {
                        stat2 = "specialAtk";
                    } else if (attack.effect.contains("EFFECT_SP_DEF")) {
                        stat2 = "specialDef";
                    } else if (attack.effect.contains("EFFECT_ACCURACY")) {
                        stat2 = "accuracy";
                    } else if (attack.effect.contains("EFFECT_EVASION")) {
                        stat2 = "evasion";
                    } else if (attack.effect.contains("EFFECT_ALL")) {
                        stat2 = "all";
                    }
                    if (stat2 != null) {
                        Pokemon target = friendlyPokemon;
                        if (!attack.effect.contains("UP_HIT") && (attack.effect.contains("HIT") || attack.name.equals("growl") || attack.name.equals("leer") || attack.name.equals("screech") || attack.name.equals("spider web") || attack.name.equals("string shot") || attack.name.equals("tail whip") || attack.name.equals("sand attack") || attack.name.equals("smokescreen") || attack.name.equals("kinesis") || attack.name.equals("flash") || attack.name.equals("mud slap") || attack.name.equals("octazooka") || attack.name.equals("cotton spore") || attack.name.equals("play rough") || attack.name.equals("sweet scent") || attack.name.equals("scary face") || attack.name.equals("charm"))) {
                            target = enemyPokemon;
                        }
                        if (attack.effect.contains("HIT")) {
                            int accuracy5 = (attack.effectChance * 255) / 100;
                            attackMisses = accuracy5 < 255 && game.map.rand.nextInt(256) >= accuracy5;
                        }
                        if (!attackMisses || (target == friendlyPokemon && !attack.name.equals("ancientpower"))) {
                            int stage = 1;
                            if (attack.effect.contains(TlbConst.TYPELIB_MAJOR_VERSION_OFFICE)) {
                                stage = 2;
                            }
                            if (attack.effect.contains("DOWN")) {
                                stage *= -1;
                            }
                            boolean worked = target.gen2ApplyStatStage(stat2, stage);
                            String text6 = null;
                            if (worked) {
                                if (stat2.equals("specialAtk")) {
                                    stat2 = "special attack";
                                } else if (stat2.equals("specialDef")) {
                                    stat2 = "special defense";
                                }
                                if (stat2.equals("all")) {
                                    text6 = target.nickname.toUpperCase(Locale.ROOT) + "' stats went up!";
                                } else if (stage == 2) {
                                    text6 = target.nickname.toUpperCase(Locale.ROOT) + "' " + stat2.toUpperCase(Locale.ROOT) + " went way up!";
                                } else if (stage == 1) {
                                    text6 = target.nickname.toUpperCase(Locale.ROOT) + "' " + stat2.toUpperCase(Locale.ROOT) + " went up!";
                                } else if (stage == -1) {
                                    text6 = target.nickname.toUpperCase(Locale.ROOT) + "' " + stat2.toUpperCase(Locale.ROOT) + " fell!";
                                } else if (stage == -2) {
                                    text6 = target.nickname.toUpperCase(Locale.ROOT) + "' " + stat2.toUpperCase(Locale.ROOT) + " sharply fell!";
                                }
                            } else if (!attack.effect.contains("HIT")) {
                                text6 = target.nickname.toUpperCase(Locale.ROOT) + "' " + stat2.toUpperCase(Locale.ROOT) + " wonì go any " + (stage > 0 ? "higher!" : "lower!");
                            }
                            if (worked && !attack.effect.contains("HIT")) {
                                attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            }
                            if (text6 != null) {
                                if (worked && !attack.effect.contains("HIT") && target != friendlyPokemon) {
                                    attackAction.append(new LoadAndPlayAnimation(game, "stat_stage_hit", enemyPokemon, null));
                                }
                                attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, text6, (String) null, true, false, (Action) new WaitFrames(game, 30, null)))));
                            }
                        } else if (!attack.effect.contains("HIT")) {
                            attackAction.append(new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, true, true, nextAction)))));
                            return attackAction;
                        }
                    }
                    String status2 = null;
                    String enemy3 = isFriendly ? "Enemy " : "";
                    if (attack.effect.contains("EFFECT_PARALYZE")) {
                        status2 = "paralyze";
                    } else if (attack.effect.equals("EFFECT_SLEEP")) {
                        status2 = "sleep";
                    } else if (attack.effect.contains("EFFECT_POISON")) {
                        status2 = "poison";
                    } else if (attack.effect.contains("EFFECT_CONFUSE")) {
                        status2 = "confuse";
                    } else if (attack.effect.contains("EFFECT_BURN")) {
                        status2 = "burn";
                    } else if (attack.effect.contains("EFFECT_FREEZE")) {
                        status2 = "freeze";
                    } else if (attack.effect.contains("EFFECT_TOXIC")) {
                        status2 = "toxic";
                    } else if (attack.effect.contains("EFFECT_ATTRACT")) {
                        status2 = "attract";
                    }
                    if (status2 != null) {
                        if (attack.effect.contains("HIT")) {
                            int accuracy6 = (attack.effectChance * 255) / 100;
                            attackMisses = accuracy6 < 255 && game.map.rand.nextInt(256) >= accuracy6;
                        }
                        if (attack.type.equals("electric") && enemyPokemon.types.contains("ELECTRIC") && status2.equals("paralyze")) {
                            attackMisses = true;
                        }
                        if (attack.type.equals("poison") && enemyPokemon.types.contains("STEEL") && (status2.equals("poison") || status2.equals("toxic"))) {
                            attackMisses = true;
                        }
                        if (attack.type.equals("electric") && enemyPokemon.types.contains("ELECTRIC")) {
                            attackMisses = true;
                        }
                        if (attack.type.equals("poison") && enemyPokemon.types.contains("POISON") && (status2.equals("poison") || status2.equals("toxic"))) {
                            attackMisses = true;
                        }
                        if (attack.type.equals("ice") && enemyPokemon.types.contains("ICE") && status2.equals("freeze")) {
                            attackMisses = true;
                        }
                        if (attack.type.equals("fire") && enemyPokemon.types.contains("FIRE") && status2.equals("burn")) {
                            attackMisses = true;
                        }
                        if (attack.name.equals("attract") && (friendlyPokemon.gender.equals(Constants.UNKNOWN) || enemyPokemon.gender.equals(Constants.UNKNOWN) || friendlyPokemon.gender == enemyPokemon.gender)) {
                            attackMisses = true;
                        }
                        boolean volatileStatus = false;
                        boolean newVolatileStatus = false;
                        if (status2.equals("confuse") || status2.equals("attract")) {
                            volatileStatus = true;
                            newVolatileStatus = true;
                            int i6 = 0;
                            while (true) {
                                if (i6 >= enemyPokemon.volatileStatus.size()) {
                                    break;
                                } else if (enemyPokemon.volatileStatus.get(i6).equals(status2)) {
                                    newVolatileStatus = false;
                                    attackMisses = true;
                                    break;
                                } else {
                                    i6++;
                                }
                            }
                        }
                        if ((attackMisses || (!volatileStatus && enemyPokemon.status != null)) && !attack.effect.contains("HIT")) {
                            attackAction.append(new WaitFrames(game, 30, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, true, true, nextAction)))));
                            return attackAction;
                        }
                        if (!attackMisses && !volatileStatus) {
                            if (isFriendly ? game.battle.oppSafeguardDown : game.battle.playerSafeguardDown) {
                                attackAction.append(new WaitFrames(game, 30, null));
                                attackAction.append(new DisplayText.Clear(game, null));
                                attackAction.append(new WaitFrames(game, 3, null));
                                attackAction.append(new DisplayText(game, enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " is protected by SAFEGUARD!", (String) null, true, true, nextAction));
                                return attackAction;
                            }
                        }
                        if (!attackMisses && (enemyPokemon.status == null || newVolatileStatus)) {
                            if (!attack.effect.contains("HIT")) {
                                attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, null));
                            } else {
                                attackAction.append(new WaitFrames(game, 49, null));
                            }
                            if (!status2.equals("sleep") && !status2.equals("poison") && !status2.equals("attract")) {
                                attackAction.append(new LoadAndPlayAnimation(game, "status_" + status2, enemyPokemon, null));
                            }
                            attackAction.append(new WaitFrames(game, 30, null));
                            String text7 = null;
                            if (status2.equals("paralyze")) {
                                enemyPokemon.currentStats.put("speed", Integer.valueOf(enemyPokemon.currentStats.get("speed").intValue() / 4));
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " was PARALYZED! It might not be able to attack!";
                            } else if (status2.equals("burn")) {
                                enemyPokemon.currentStats.put("attack", Integer.valueOf(enemyPokemon.currentStats.get("attack").intValue() / 4));
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " was burned!";
                            } else if (status2.equals("sleep")) {
                                enemyPokemon.statusCounter = game.map.rand.nextInt(5) + 1;
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " fell asleep!";
                            } else if (status2.equals("poison")) {
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " was poisoned!";
                            } else if (status2.equals("confuse")) {
                                enemyPokemon.volatileStatusCounter.put(status2, Integer.valueOf(game.map.rand.nextInt(5) + 1));
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " is confused!";
                            } else if (status2.equals("freeze")) {
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "' frozen solid!";
                            } else if (status2.equals("toxic")) {
                                enemyPokemon.statusCounter = 1;
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "' badly poisoned!";
                            } else if (status2.equals("attract")) {
                                text7 = enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " became infatuated with " + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "!";
                            }
                            if (text7 != null) {
                                attackAction.append(new DisplayText.Clear(game, null));
                                attackAction.append(new WaitFrames(game, 3, null));
                                attackAction.append(new DisplayText(game, text7, (String) null, true, true, (Action) null));
                                if (status2.equals("confuse") || status2.equals("attract")) {
                                    enemyPokemon.volatileStatus.add(status2);
                                } else {
                                    attackAction.append(new SetField(enemyPokemon, "status", status2, null));
                                }
                            }
                        }
                    }
                    if (attack.name.equals("disable")) {
                        int attackIndex2 = DrawBattle.prevFriendlyAttackIndex;
                        if (isFriendly) {
                            attackIndex2 = DrawBattle.prevEnemyAttackIndex;
                        }
                        if (attackIndex2 == -1 || enemyPokemon.disabledIndex >= 0) {
                            attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null))));
                        } else {
                            enemyPokemon.disabledIndex = attackIndex2;
                            enemyPokemon.disabledCounter = game.map.rand.nextInt(7) + 2;
                            attackAction.append(new LoadAndPlayAnimation(game, attack.name, enemyPokemon, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy3 + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + enemyPokemon.attacks[attackIndex2].toUpperCase(Locale.ROOT) + " was disabled!", (String) null, false, true, (Action) null)))));
                        }
                    } else if (attack.effect.equals("EFFECT_SKETCH")) {
                        int attackIndex3 = DrawBattle.prevFriendlyAttackIndex;
                        if (isFriendly) {
                            attackIndex3 = DrawBattle.prevEnemyAttackIndex;
                        }
                        if (attackIndex3 == -1) {
                            attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "But it failed!", (String) null, false, true, (Action) null))));
                        } else {
                            int index = 0;
                            String[] strArr = friendlyPokemon.attacks;
                            int length = strArr.length;
                            int i7 = 0;
                            while (i7 < length && !strArr[i7].equals(attack.name)) {
                                index++;
                                i7++;
                            }
                            friendlyPokemon.attacks[index] = enemyPokemon.attacks[attackIndex3];
                            attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " sketched " + enemyPokemon.attacks[attackIndex3].toUpperCase(Locale.ROOT) + "!", (String) null, false, true, (Action) null))));
                        }
                    } else if (attack.effect.equals("EFFECT_TRANSFORM")) {
                        attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new RunCode(() -> {
                            Pokemon pokemon = new Pokemon(enemyPokemon.specie.name, friendlyPokemon.level);
                            String[] statNames = {"hp", "attack", "defense", "specialAtk", "specialDef", "speed"};
                            for (String statName : statNames) {
                                pokemon.currentStats.put(statName, friendlyPokemon.currentStats.get(statName));
                            }
                            for (int i8 = 0; i8 < 4; i8++) {
                                pokemon.attacks[i8] = enemyPokemon.attacks[i8];
                            }
                            pokemon.types = new ArrayList<>(friendlyPokemon.types);
                            pokemon.nickname = friendlyPokemon.nickname;
                            pokemon.gender = friendlyPokemon.gender;
                            pokemon.happiness = friendlyPokemon.happiness;
                            pokemon.status = friendlyPokemon.status;
                            pokemon.statusCounter = friendlyPokemon.statusCounter;
                            pokemon.trappedBy = friendlyPokemon.trappedBy;
                            pokemon.trapCounter = friendlyPokemon.trapCounter;
                            pokemon.sprite.setX(friendlyPokemon.sprite.getX());
                            pokemon.sprite.setY(friendlyPokemon.sprite.getY());
                            pokemon.exp = friendlyPokemon.exp;
                            pokemon.position = friendlyPokemon.position.cpy();
                            SpriteProxy enemySprite = enemyPokemon.sprite;
                            SpriteProxy friendlySprite = friendlyPokemon.sprite;
                            SpriteProxy targetSprite = pokemon.sprite;
                            if (isFriendly) {
                                enemySprite = enemyPokemon.backSprite;
                                friendlySprite = friendlyPokemon.backSprite;
                                targetSprite = pokemon.backSprite;
                            }
                            Color color = new Color();
                            TextureData temp = enemySprite.getTexture().getTextureData();
                            if (!temp.isPrepared()) {
                                temp.prepare();
                            }
                            Pixmap pixmap = temp.consumePixmap();
                            for (int m = 0; m < pixmap.getWidth(); m++) {
                                for (int n = 0; n < pixmap.getHeight(); n++) {
                                    color.set(pixmap.getPixel(m, n));
                                    if (color.equals(enemySprite.color1)) {
                                        color = friendlySprite.color1;
                                    } else if (color.equals(enemySprite.color2)) {
                                        color = friendlySprite.color2;
                                    }
                                    pixmap.drawPixel(m, n, Color.argb8888(color));
                                }
                            }
                            targetSprite.setTexture(TextureCache.get(pixmap));
                            targetSprite.setRegion(enemySprite);
                            if (isFriendly) {
                                game.player.currPokemon = pokemon;
                            } else {
                                game.battle.oppPokemon = pokemon;
                            }
                        }, new DisplayText(game, enemy3 + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + " transformed into " + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, false, true, (Action) null)))));
                    }
                    if (enemyPokemon.trappedBy == null && !attackMisses && (attack.effect.equals("EFFECT_TRAP_TARGET") || attack.effect.equals("EFFECT_BIND"))) {
                        attackAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, (isFriendly ? "Enemy " : "") + enemyPokemon.nickname.toUpperCase(Locale.ROOT) + " was trapped!", (String) null, true, true, (Action) null))));
                        enemyPokemon.trappedBy = attack.name.toLowerCase(Locale.ROOT);
                        enemyPokemon.trapCounter = game.map.rand.nextInt(4) + 2;
                        if (attack.name.toLowerCase(Locale.ROOT).equals("thunder cage")) {
                            enemyPokemon.trapCounter = game.map.rand.nextInt(2) + 4;
                        }
                    }
                    attackAction.append(nextAction);
                    return attackAction;
                }
                int lockedMove5 = game.battle.oppLockedMove;
                if (isFriendly) {
                    lockedMove5 = game.battle.playerLockedMove;
                }
                boolean resetHidden3 = false;
                if (lockedMove5 != -1) {
                    if (friendlyPokemon.attacks[lockedMove5].equals("dig") || friendlyPokemon.attacks[lockedMove5].equals("fly")) {
                        resetHidden3 = true;
                    }
                    if (isFriendly) {
                        game.battle.playerLockedMove = -1;
                        if (friendlyPokemon.attacks[lockedMove5].equals("dig")) {
                            game.battle.playerUnderground = false;
                        } else if (friendlyPokemon.attacks[lockedMove5].equals("fly")) {
                            game.battle.playerAirborne = false;
                        }
                    } else {
                        game.battle.oppLockedMove = -1;
                        if (friendlyPokemon.attacks[lockedMove5].equals("dig")) {
                            game.battle.oppUnderground = false;
                        } else if (friendlyPokemon.attacks[lockedMove5].equals("fly")) {
                            game.battle.oppAirborne = false;
                        }
                    }
                }
                Action disabledAction = new Action(new Object[0]);
                disabledAction.append(new DisplayText.Clear(game, null));
                disabledAction.append(new WaitFrames(game, 3, null));
                disabledAction.append(new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' " + attack.name.toUpperCase(Locale.ROOT) + " is DISABLED!", (String) null, (Action) null, (Action) null));
                disabledAction.append(new WaitFrames(game, 10, null));
                if (resetHidden3) {
                    String field3 = "hideOppPokemon";
                    if (isFriendly) {
                        field3 = "hideOwnPokemon";
                    }
                    disabledAction.append(new SetField(game.battle.drawAction, field3, false, null));
                }
                disabledAction.append(nextAction);
                return disabledAction;
            } else if (isFriendly) {
                return new Attack.Default(game, 40, 100, nextAction);
            } else {
                return new Attack.Lick(game, game.battle.oppPokemon, game.player.currPokemon, nextAction);
            }
        }
        if (isFriendly) {
            return new Attack.Default(game, power, accuracy, nextAction);
        }
        return new Attack.DefaultEnemy(game.battle.oppPokemon, game.player.currPokemon, power, accuracy, nextAction);
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$GetIntroAction.class */
    public static class GetIntroAction extends Action {
        public Action.Layer layer = Action.Layer.map_0;

        public GetIntroAction(Action nextAction) {
            super(new Object[0]);
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "map";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void firstStep(Game game) {
            game.insertAction(Battle.getIntroAction(game));
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
        }
    }

    public static Action getIntroAction(Game game) {
        return getIntroAction(game, false);
    }

    public static Action getIntroAction(Game game, boolean fishing) {
        Action triggerAction;
        Action action;
        Action action2;
        game.battle.resetState();
        DrawBattle.hideOwnPokemon = false;
        DrawBattle.hideOppPokemon = false;
        if (game.player.pokemon.isEmpty()) {
            return new SplitAction(new BattleIntro(new BattleIntroAnim1(new SplitAction(new DrawBattle(game), new BattleAnimPositionPlayers(game, new PlayMusic(game.battle.oppPokemon, new DisplayText(game, "Wild " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " appeared!", (String) null, (Action) null, new WaitFrames(game, 39, game.player.adrenaline > 0 ? new DisplayText(game, "" + game.player.name + " has ADRENALINE " + Integer.toString(game.player.adrenaline) + "!", (String) null, (Action) null, new PrintAngryEating(game, new DrawBattleMenuSafariZone(game, null))) : new PrintAngryEating(game, new DrawBattleMenuSafariZone(game, null))))))))), null);
        } else if (game.battle.oppPokemon.generation == Pokemon.Generation.CRYSTAL) {
            if (game.player.currPokemon.generation == Pokemon.Generation.RED) {
                triggerAction = new PlayMusic(game.player.currPokemon.specie.name, new WaitFrames(game, 6, new DrawBattleMenuNormal(game, null)));
            } else {
                triggerAction = new PlaySound(game.player.currPokemon, new WaitFrames(game, game.player.currPokemon.specie.cryLengthInFrames(), new WaitFrames(game, 6, new DrawFriendlyHealthGen2(game, new WaitFrames(game, 15, new DrawBattleMenuNormal(game, null))))));
            }
            Action introAction = new BattleIntro(new BattleIntroAnim1(new SplitAction(new DrawBattle(game), new BattleAnimPositionPlayers(game, null))));
            if (game.battle.oppPokemon.isShiny) {
                introAction.append(new LoadAndPlayAnimation(game, "shiny", game.player.currPokemon, null));
            }
            introAction.append(new SplitAction(new WaitFrames(game, 4, new PlaySound(game.battle.oppPokemon, (Action) null)), new PokemonIntroAnim(new WaitFrames(game, 11, null))));
            if (game.battle.oppPokemon.aggroPlayer) {
                introAction.append(new DisplayText(game, "Angry " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " attacked!", (String) null, (Action) null, new DisplayText(game, "Enemy " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + "' attack went way up!", (String) null, (Action) null, (Action) null)));
                game.battle.oppPokemon.gen2ApplyStatStage("attack", 2);
            } else if (fishing) {
                introAction.append(new DisplayText(game, "Unhooked " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " attacked!", (String) null, (Action) null, (Action) null));
            } else {
                introAction.append(new DisplayText(game, "Wild " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " appeared!", (String) null, (Action) null, (Action) null));
            }
            if (game.battle.oppPokemon.isTrapping) {
                introAction.append(new DisplayText(game, "It' holding your leg! You canì flee!", (String) null, (Action) null, (Action) null));
            }
            WaitFrames waitFrames = new WaitFrames(game, 1, new DrawEnemyHealthGen2(game));
            String str = "Go! " + game.player.currPokemon.nickname.toUpperCase(Locale.ROOT) + "!";
            if (game.player.currPokemon.generation == Pokemon.Generation.RED) {
                action = new SplitAction(new DrawFriendlyHealthGen2(game), new ThrowOutPokemon(game, triggerAction));
            } else {
                if (game.player.currPokemon.isShiny) {
                    action2 = new LoadAndPlayAnimation(game, "shiny", game.battle.oppPokemon, triggerAction);
                } else {
                    action2 = triggerAction;
                }
                action = new ThrowOutPokemonCrystal(game, action2);
            }
            introAction.append(new SplitAction(waitFrames, new WaitFrames(game, 39, new MovePlayerOffScreen(game, new DisplayText(game, str, (String) null, triggerAction, action)))));
            return introAction;
        } else {
            Action triggerAction2 = new PlayMusic(game.player.currPokemon.specie.name, new WaitFrames(game, 6, new DrawBattleMenuNormal(game, null)));
            return new BattleIntro(new BattleIntroAnim1(new SplitAction(new DrawBattle(game), new BattleAnimPositionPlayers(game, new PlayMusic(game.battle.oppPokemon.specie.name, new DisplayText(game, "Wild " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " appeared!", (String) null, (Action) null, new SplitAction(new WaitFrames(game, 1, new DrawEnemyHealthGen2(game)), new WaitFrames(game, 39, new MovePlayerOffScreen(game, new DisplayText(game, "Go! " + game.player.currPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, triggerAction2, new SplitAction(new DrawFriendlyHealthGen2(game), new ThrowOutPokemon(game, triggerAction2))))))))))));
        }
    }

    public void resetState() {
        this.turnNumber = 1;
        this.playerReflectDown = false;
        this.oppReflectDown = false;
        this.playerReflectCounter = 0;
        this.oppReflectCounter = 0;
        this.playerLightScreenDown = false;
        this.oppLightScreenDown = false;
        this.playerLightScreenCounter = 0;
        this.oppLightScreenCounter = 0;
        this.weather = null;
        this.weatherCounter = 0;
        this.playerAirborne = false;
        this.playerUnderground = false;
        this.oppAirborne = false;
        this.oppUnderground = false;
        this.playerSafeguardDown = false;
        this.playerSafeguardCounter = 0;
        this.oppSafeguardDown = false;
        this.oppSafeguardCounter = 0;
        this.playerLockedMove = -1;
        this.playerLockedMoveCounter = 0;
        this.oppLockedMove = -1;
        this.oppLockedMoveCounter = 0;
        this.playerSpikesDown = false;
        this.oppSpikesDown = false;
    }

    public Battle() {
        FileHandle musicMod = Gdx.files.local("mods/wild_battle.ogg");
        if (musicMod.exists()) {
            System.out.println("Found battle music mod.");
            this.music = AudioLoader.loadMusic(musicMod.path());
        } else {
            this.music = new LinkedMusic("music/wild_battle_intro", "music/wild_battle");
        }
        this.victoryFanfare = new LinkedMusic("music/victory_fanfare1_intro", "music/victory_fanfare1");
        this.victoryFanfare.setVolume(1.0f);
        this.gen2TypeEffectiveness = new HashMap<>();
        this.gen2TypeEffectiveness.put("normal", new HashMap<>());
        this.gen2TypeEffectiveness.get("normal").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("rock", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("normal").put("ghost", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("normal").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("normal").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("normal").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("fire", new HashMap<>());
        this.gen2TypeEffectiveness.get("fire").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("fire", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fire").put("water", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fire").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("grass", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fire").put("ice", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fire").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("bug", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fire").put("rock", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fire").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("dragon", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fire").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fire").put("steel", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fire").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("water", new HashMap<>());
        this.gen2TypeEffectiveness.get("water").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("fire", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("water").put("water", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("water").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("grass", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("water").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("ground", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("water").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("rock", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("water").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("dragon", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("water").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("steel", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("water").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("electric", new HashMap<>());
        this.gen2TypeEffectiveness.get("electric").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("water", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("electric").put("electric", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("electric").put("grass", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("electric").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("ground", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("electric").put("flying", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("electric").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("dragon", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("electric").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("steel", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("electric").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("grass", new HashMap<>());
        this.gen2TypeEffectiveness.get("grass").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("fire", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("water", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("grass").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("grass", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("poison", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("ground", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("grass").put("flying", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("bug", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("rock", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("grass").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("dragon", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("grass").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("grass").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("ice", new HashMap<>());
        this.gen2TypeEffectiveness.get("ice").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("fire", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ice").put("water", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ice").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("grass", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ice").put("ice", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ice").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("ground", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ice").put("flying", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ice").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("dragon", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ice").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ice").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ice").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("fighting", new HashMap<>());
        this.gen2TypeEffectiveness.get("fighting").put("normal", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fighting").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("ice", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fighting").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("poison", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fighting").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("flying", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fighting").put("psychic", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fighting").put("bug", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fighting").put("rock", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fighting").put("ghost", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("fighting").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fighting").put("dark", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fighting").put("steel", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fighting").put("fairy", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.put("poison", new HashMap<>());
        this.gen2TypeEffectiveness.get("poison").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("grass", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("poison").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("poison", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("poison").put("ground", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("poison").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("rock", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("poison").put("ghost", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("poison").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("poison").put("steel", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("poison").put("fairy", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.put("ground", new HashMap<>());
        this.gen2TypeEffectiveness.get("ground").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("fire", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ground").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("electric", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ground").put("grass", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ground").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("poison", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ground").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("flying", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("ground").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("bug", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ground").put("rock", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ground").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ground").put("steel", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ground").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("flying", new HashMap<>());
        this.gen2TypeEffectiveness.get("flying").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("electric", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("flying").put("grass", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("flying").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("fighting", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("flying").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("bug", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("flying").put("rock", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("flying").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("flying").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("flying").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("psychic", new HashMap<>());
        this.gen2TypeEffectiveness.get("psychic").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("fighting", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("psychic").put("poison", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("psychic").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("psychic", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("psychic").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("psychic").put("dark", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("psychic").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("psychic").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("bug", new HashMap<>());
        this.gen2TypeEffectiveness.get("bug").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("fire", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("bug").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("grass", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("bug").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("fighting", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("bug").put("poison", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("bug").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("flying", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("bug").put("psychic", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("bug").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("ghost", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("bug").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("bug").put("dark", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("bug").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("bug").put("fairy", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.put("rock", new HashMap<>());
        this.gen2TypeEffectiveness.get("rock").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("fire", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("rock").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("ice", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("rock").put("fighting", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("rock").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("ground", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("rock").put("flying", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("rock").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("bug", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("rock").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("rock").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("rock").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("ghost", new HashMap<>());
        this.gen2TypeEffectiveness.get("ghost").put("normal", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.get("ghost").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("psychic", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ghost").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("ghost", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("ghost").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("dark", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("ghost").put("steel", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("ghost").put("fairy", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.put("dragon", new HashMap<>());
        this.gen2TypeEffectiveness.get("dragon").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("dragon", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("dragon").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dragon").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("dragon").put("fairy", Float.valueOf(0.0f));
        this.gen2TypeEffectiveness.put("dark", new HashMap<>());
        this.gen2TypeEffectiveness.get("dark").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("fire", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("fighting", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("dark").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("psychic", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("dark").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("ghost", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("dark").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("dark", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("dark").put("steel", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("dark").put("fairy", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.put("steel", new HashMap<>());
        this.gen2TypeEffectiveness.get("steel").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("fire", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("steel").put("water", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("steel").put("electric", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("steel").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("ice", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("steel").put("fighting", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("poison", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("rock", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("steel").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("dragon", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("dark", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("steel").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("steel").put("fairy", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.put("fairy", new HashMap<>());
        this.gen2TypeEffectiveness.get("fairy").put("normal", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("fire", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fairy").put("water", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("electric", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("grass", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("ice", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("fighting", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fairy").put("poison", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fairy").put("ground", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("flying", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("psychic", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("bug", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("rock", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("ghost", Float.valueOf(1.0f));
        this.gen2TypeEffectiveness.get("fairy").put("dragon", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fairy").put("dark", Float.valueOf(2.0f));
        this.gen2TypeEffectiveness.get("fairy").put("steel", Float.valueOf(0.5f));
        this.gen2TypeEffectiveness.get("fairy").put("fairy", Float.valueOf(1.0f));
        try {
            Reader reader = Gdx.files.internal("pokemon/moves.asm").reader();
            BufferedReader br = new BufferedReader(reader);
            while (true) {
                String line = br.readLine();
                if (line == null) {
                    break;
                } else if (line.contains("\tmove ") && !line.contains(";")) {
                    String[] attrs = line.split("\tmove ")[1].split(",\\s+");
                    Attack attack = new Attack(attrs[0].toLowerCase(Locale.ROOT).replace('_', ' '), attrs[1], Integer.valueOf(attrs[2]).intValue(), attrs[3].toLowerCase(Locale.ROOT), Integer.valueOf(attrs[4]).intValue(), Integer.valueOf(attrs[5]).intValue(), Integer.valueOf(attrs[6]).intValue());
                    this.attacks.put(attack.name, attack);
                }
            }
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        Attack attack2 = new Attack("Mewtwo_Special1", "EFFECT_NORMAL_HIT", 0, "psychic", 100, 1, 100);
        attack2.category = Attack.Category.SPECIAL;
        this.attacks.put(attack2.name, attack2);
        Attack attack3 = new Attack("confusion_hit", "EFFECT_NORMAL_HIT", 40, "normal", 100, 1, 100);
        attack3.category = Attack.Category.PHYSICAL;
        this.attacks.put(attack3.name, attack3);
        Attack attack4 = new Attack("Regigigas_Special1", "EFFECT_NORMAL_HIT", 40, "ground", 100, 1, 100);
        attack4.category = Attack.Category.PHYSICAL;
        this.attacks.put(attack4.name, attack4);
    }

    public int calcFaintExp(int numParticipated) {
        int b = this.oppPokemon.baseStats.get("baseExp").intValue();
        return (((((1 * 1) * b) * 1) * this.oppPokemon.level) / (7 * numParticipated)) * 5;
    }

    public boolean calcIfRunSuccessful(Game game, Player player) {
        int b;
        int x;
        if (player.currPokemon.cantEscapeBy != null) {
            return false;
        }
        int currSpeed = player.currPokemon.currentStats.get("speed").intValue();
        int oppSpeed = this.oppPokemon.currentStats.get("speed").intValue();
        if (currSpeed < oppSpeed && (b = (oppSpeed / 4) % 256) != 0 && (x = ((currSpeed * 32) / b) + (30 * (player.numFlees + 1))) <= 255 && game.map.rand.nextInt(256) >= x) {
            return false;
        }
        return true;
    }

    public static Action depleteHealth(Game game, boolean isFriendly, int damage, Action nextAction) {
        return depleteHealth(game, isFriendly, damage, true, nextAction);
    }

    public static Action depleteHealth(Game game, boolean isFriendly, int damage, boolean detectFaint, Action nextAction) {
        Action newAction;
        if (!isFriendly) {
            newAction = new DepleteFriendlyHealth(game.player.currPokemon, damage, null);
        } else {
            newAction = new DepleteEnemyHealth(game, damage, null);
        }
        if (detectFaint) {
            newAction.append(detectFaint(game, isFriendly, null));
        }
        newAction.append(nextAction);
        return newAction;
    }

    public static Action detectFaint(Game game, boolean isFriendly, Action nextAction) {
        return detectFaint(game, isFriendly, true, nextAction);
    }

    public static Action detectFaint(Game game, boolean isFriendly, boolean checkEndOfBattle, Action nextAction) {
        Action newAction;
        if (!isFriendly) {
            newAction = new DetectFriendlyFaint(game.player.currPokemon, checkEndOfBattle, null);
        } else {
            newAction = new DetectEnemyFaint(checkEndOfBattle, null);
        }
        newAction.append(nextAction);
        return newAction;
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$CheckTrapped.class */
    public class CheckTrapped extends Action {
        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public CheckTrapped(Game game, Action nextAction) {
            super(new Object[0]);
            Battle.this = this$0;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            Action action = new Action(new Object[0]) { // from class: com.corona.game.Battle.CheckTrapped.1
                @Override // com.corona.game.Action
                public String getCamera() {
                    return "gui";
                }
            };
            if (game.player.currPokemon.trappedBy != null) {
                Attack trap = game.battle.attacks.get(game.player.currPokemon.trappedBy);
                trap.damage = Battle.gen2CalcDamage(game.battle.oppPokemon, trap, game.player.currPokemon);
                if (trap.name.equals("thunder cage")) {
                    trap.damage = game.player.currPokemon.maxStats.get("hp").intValue() / 8;
                }
                action.append(new LoadAndPlayAnimation(game, game.player.currPokemon.trappedBy, game.player.currPokemon, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, game.player.currPokemon.nickname.toUpperCase(Locale.ROOT) + "' hurt by " + game.player.currPokemon.trappedBy.toUpperCase(Locale.ROOT) + "!", (String) null, true, (Action) new DepleteFriendlyHealth(game.player.currPokemon, trap.damage, new DetectFriendlyFaint(game.player.currPokemon, true, new WaitFrames(game, 13, null))))))));
                game.player.currPokemon.trapCounter--;
                if (game.player.currPokemon.trapCounter <= 0) {
                    game.player.currPokemon.trappedBy = null;
                }
            }
            if (game.battle.oppPokemon.trappedBy != null) {
                Attack trap2 = game.battle.attacks.get(game.battle.oppPokemon.trappedBy);
                trap2.damage = Battle.gen2CalcDamage(game.player.currPokemon, trap2, game.battle.oppPokemon);
                if (trap2.name.equals("thunder cage")) {
                    trap2.damage = game.battle.oppPokemon.maxStats.get("hp").intValue() / 8;
                }
                action.append(new LoadAndPlayAnimation(game, game.battle.oppPokemon.trappedBy, game.battle.oppPokemon, new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + "' hurt by " + game.battle.oppPokemon.trappedBy.toUpperCase(Locale.ROOT) + "!", (String) null, true, (Action) new DepleteEnemyHealth(game, trap2.damage, new DetectEnemyFaint(true, new WaitFrames(game, 13, null))))))));
                game.battle.oppPokemon.trapCounter--;
                if (game.battle.oppPokemon.trapCounter <= 0) {
                    game.battle.oppPokemon.trappedBy = null;
                }
            }
            action.append(this.nextAction);
            game.actionStack.remove(this);
            game.insertAction(action);
        }
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$CheckScreens.class */
    public class CheckScreens extends Action {
        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public CheckScreens(Game game, Action nextAction) {
            super(new Object[0]);
            Battle.this = this$0;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            Action action = new Action(new Object[0]) { // from class: com.corona.game.Battle.CheckScreens.1
                @Override // com.corona.game.Action
                public String getCamera() {
                    return "gui";
                }
            };
            if (game.battle.playerReflectDown) {
                game.battle.playerReflectCounter--;
                if (game.battle.playerReflectCounter <= 0) {
                    game.battle.playerReflectDown = false;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, "Player POKéMON' REFLECT faded!", (String) null, true, true, (Action) null));
                }
            }
            if (game.battle.oppReflectDown) {
                game.battle.oppReflectCounter--;
                if (game.battle.oppReflectCounter <= 0) {
                    game.battle.oppReflectDown = false;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, "Enemy POKéMON' REFLECT faded!", (String) null, true, true, (Action) null));
                }
            }
            if (game.battle.playerLightScreenDown) {
                game.battle.playerLightScreenCounter--;
                if (game.battle.playerLightScreenCounter <= 0) {
                    game.battle.playerLightScreenDown = false;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, "Player POKéMON' LIGHT SCREEN faded!", (String) null, true, true, (Action) null));
                }
            }
            if (game.battle.oppLightScreenDown) {
                game.battle.oppLightScreenCounter--;
                if (game.battle.oppLightScreenCounter <= 0) {
                    game.battle.oppLightScreenDown = false;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, "Enemy POKéMON' LIGHT SCREEN faded!", (String) null, true, true, (Action) null));
                }
            }
            if (game.battle.playerSafeguardDown) {
                game.battle.playerSafeguardCounter--;
                if (game.battle.playerSafeguardCounter <= 0) {
                    game.battle.playerSafeguardDown = false;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, game.player.currPokemon.nickname.toUpperCase(Locale.ROOT) + "' SAFEGUARD faded!", (String) null, true, true, (Action) null));
                }
            }
            if (game.battle.oppSafeguardDown) {
                game.battle.oppSafeguardCounter--;
                if (game.battle.oppSafeguardCounter <= 0) {
                    game.battle.oppSafeguardDown = false;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, "Enemy " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + "' SAFEGUARD faded!", (String) null, true, true, (Action) null));
                }
            }
            action.append(this.nextAction);
            game.actionStack.remove(this);
            game.insertAction(action);
        }
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$CheckWeather.class */
    public class CheckWeather extends Action {
        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public CheckWeather(Game game, Action nextAction) {
            super(new Object[0]);
            Battle.this = this$0;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            Action action = new Action(new Object[0]) { // from class: com.corona.game.Battle.CheckWeather.1
                @Override // com.corona.game.Action
                public String getCamera() {
                    return "gui";
                }
            };
            if (game.battle.weather != null) {
                game.battle.weatherCounter--;
                if (game.battle.weatherCounter <= 0) {
                    String text = "The rain stopped";
                    if (game.battle.weather.equals("sunny day")) {
                        text = "The sunlight faded.";
                    } else if (game.battle.weather.equals("sandstorm")) {
                        text = "The SANDSTORM subsided.";
                    }
                    game.battle.weather = null;
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, text, (String) null, true, true, (Action) null));
                } else {
                    String text2 = "Rain continues to fall.";
                    if (game.battle.weather.equals("sunny day")) {
                        text2 = "The sunlight is strong.";
                    } else if (game.battle.weather.equals("sandstorm")) {
                        text2 = "The SANDSTORM rages.";
                    }
                    action.append(new DisplayText.Clear(game, null));
                    action.append(new WaitFrames(game, 3, null));
                    action.append(new DisplayText(game, text2, (String) null, true, true, (Action) null));
                    if (game.battle.weather.equals("sandstorm")) {
                        if (!game.player.currPokemon.types.contains("STEEL") && !game.player.currPokemon.types.contains("ROCK") && !game.player.currPokemon.types.contains("GROUND")) {
                            action.append(new LoadAndPlayAnimation(game, "sandstorm_hit", game.player.currPokemon, null));
                            action.append(new DisplayText.Clear(game, null));
                            action.append(new WaitFrames(game, 3, null));
                            action.append(new DisplayText(game, "The SANDSTORM hits " + game.player.currPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, true, true, (Action) null));
                            action.append(new DepleteFriendlyHealth(game.player.currPokemon, game.player.currPokemon.maxStats.get("hp").intValue() / 8, null));
                            action.append(new DetectFriendlyFaint(game.player.currPokemon, true, null));
                            action.append(new WaitFrames(game, 13, null));
                        }
                        if (!game.battle.oppPokemon.types.contains("STEEL") && !game.battle.oppPokemon.types.contains("ROCK") && !game.battle.oppPokemon.types.contains("GROUND")) {
                            action.append(new LoadAndPlayAnimation(game, "sandstorm_hit", game.battle.oppPokemon, null));
                            action.append(new DisplayText.Clear(game, null));
                            action.append(new WaitFrames(game, 3, null));
                            action.append(new DisplayText(game, "The SANDSTORM hits Enemy " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, true, true, (Action) null));
                            action.append(new DepleteEnemyHealth(game, game.battle.oppPokemon.maxStats.get("hp").intValue() / 8, null));
                            action.append(new DetectEnemyFaint(true, null));
                            action.append(new WaitFrames(game, 13, null));
                        }
                    }
                }
            }
            action.append(this.nextAction);
            game.actionStack.remove(this);
            game.insertAction(action);
        }
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$CheckLockedMoves.class */
    public class CheckLockedMoves extends Action {
        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public CheckLockedMoves(Game game, Action nextAction) {
            super(new Object[0]);
            Battle.this = this$0;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            Action action = new Action(new Object[0]) { // from class: com.corona.game.Battle.CheckLockedMoves.1
                @Override // com.corona.game.Action
                public String getCamera() {
                    return "gui";
                }
            };
            if (game.battle.playerLockedMove != -1) {
                game.battle.playerLockedMoveCounter--;
                if (game.battle.playerLockedMoveCounter <= 0) {
                    game.battle.playerLockedMove = -1;
                }
            }
            if (game.battle.oppLockedMove != -1) {
                game.battle.oppLockedMoveCounter--;
                if (game.battle.oppLockedMoveCounter <= 0) {
                    game.battle.oppLockedMove = -1;
                }
            }
            action.append(this.nextAction);
            game.actionStack.remove(this);
            game.insertAction(action);
        }
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$CheckSpikes.class */
    public static class CheckSpikes extends Action {
        boolean isFriendly;

        public CheckSpikes(Game game, boolean isFriendly, Action nextAction) {
            super(new Object[0]);
            this.isFriendly = isFriendly;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            Action action = new Action(new Object[0]) { // from class: com.corona.game.Battle.CheckSpikes.1
                @Override // com.corona.game.Action
                public String getCamera() {
                    return "gui";
                }
            };
            Pokemon target = null;
            String enemy = "";
            boolean depleteFriendly = !this.isFriendly;
            if (this.isFriendly && game.battle.playerSpikesDown && !game.player.currPokemon.types.contains("FLYING")) {
                target = game.player.currPokemon;
            } else if (!this.isFriendly && game.battle.oppSpikesDown && !game.battle.oppPokemon.types.contains("FLYING")) {
                target = game.battle.oppPokemon;
                enemy = "Enemy ";
                depleteFriendly = this.isFriendly;
            }
            if (target != null) {
                action.append(new DisplayText.Clear(game, null));
                action.append(new WaitFrames(game, 3, null));
                action.append(Battle.depleteHealth(game, depleteFriendly, (int) Math.ceil((((double) target.maxStats.get("hp").intValue()) / 100.0d) * 12.5d), true, null));
                action.append(new DisplayText(game, enemy + target.nickname.toUpperCase(Locale.ROOT) + "' hurt by SPIKES!", (String) null, true, true, (Action) null));
                action.append(new WaitFrames(game, 13, null));
            }
            action.append(this.nextAction);
            game.actionStack.remove(this);
            game.insertAction(action);
        }
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$DoTurn.class */
    public static class DoTurn extends Action {
        Type type;

        /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$DoTurn$Type.class */
        public enum Type {
            ATTACK,
            SWITCH,
            ITEM,
            RUN
        }

        public DoTurn(Game game, Action nextAction) {
            this(game, Type.ATTACK, nextAction);
        }

        public DoTurn(Game game, Type type, Action nextAction) {
            super(new Object[0]);
            this.type = Type.ATTACK;
            this.type = type;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return Action.Layer.map_500;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            Attack enemyAttack;
            Action playerAction;
            Action doTurn;
            Attack playerAttack;
            boolean runSuccessful;
            int numWobbles;
            Action catchAction;
            String attackChoice;
            game.player.currPokemon.flinched = false;
            game.battle.oppPokemon.flinched = false;
            boolean enemyFirst = false;
            if (game.type != Game.Type.CLIENT) {
                if (game.battle.oppLockedMove != -1) {
                    enemyAttack = new Attack(game.battle.attacks.get(game.battle.oppPokemon.attacks[game.battle.oppLockedMove]));
                } else {
                    ArrayList<String> validAttacks = new ArrayList<>();
                    int i = 0;
                    String[] strArr = game.battle.oppPokemon.attacks;
                    for (String attack : strArr) {
                        if (!(attack == null || game.battle.oppPokemon.disabledIndex == i)) {
                            validAttacks.add(attack);
                        }
                        i++;
                    }
                    if (validAttacks.isEmpty()) {
                        attackChoice = "struggle";
                    } else {
                        attackChoice = validAttacks.get(game.map.rand.nextInt(validAttacks.size()));
                    }
                    enemyAttack = new Attack(game.battle.attacks.get(attackChoice.toLowerCase(Locale.ROOT)));
                }
                if (game.debugInputEnabled && Gdx.input.isKeyPressed(62)) {
                    enemyAttack.damage = 0;
                }
            } else {
                Network.BattleTurnData turnData = game.battle.network.turnData;
                enemyAttack = turnData.enemyAttack;
                game.battle.oppPokemon.trappedBy = turnData.enemyTrappedBy;
                game.battle.oppPokemon.trapCounter = turnData.enemyTrapCounter;
            }
            Action enemyAction = new AttackAnim(game, enemyAttack, 1 == 0, null);
            if (this.type == Type.SWITCH) {
                game.player.numFlees = 0;
                Pokemon nextPokemon = game.player.pokemon.get(DrawPokemonMenu.currIndex);
                playerAction = new SetField(game.player, "currPokemon", nextPokemon, new RemoveAction(game.battle.drawAction.drawFriendlyHealthAction, new SetField(game.battle.drawAction, "drawFriendlyHealthAction", null, new RemoveAction(game.battle.drawAction.drawFriendlyPokemonAction, new SetField(game.battle.drawAction, "drawFriendlyPokemonAction", null, new DrawPokemonMenu.Intro(13, new DisplayText(game, "Go! " + nextPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, true, false, (Action) new ThrowOutPokemonCrystal(game, new PlayMusic(nextPokemon, new WaitFrames(game, 6, new DrawFriendlyHealthGen2(game, new CheckSpikes(game, true, null))))))))))));
                if (enemyAttack.name.equals("pursuit")) {
                    enemyFirst = true;
                    enemyAttack.power *= 2;
                    enemyAttack.damage = Battle.gen2CalcDamage(game.battle.oppPokemon, enemyAttack, game.player.currPokemon);
                }
                game.battle.oppPokemon.cantEscapeBy = null;
                game.player.currPokemon.volatileStatus.clear();
                game.player.currPokemon.volatileStatusCounter.clear();
            } else if (this.type == Type.ITEM) {
                game.player.numFlees = 0;
                Network.BattleTurnData turnData2 = game.battle.network.turnData;
                String itemName = turnData2.itemName.toLowerCase(Locale.ROOT);
                if (itemName.contains("ball")) {
                    if (game.type != Game.Type.CLIENT) {
                        numWobbles = Battle.gen2CalcIfCaught(game, game.battle.oppPokemon, itemName);
                    } else {
                        numWobbles = turnData2.numWobbles;
                    }
                    if (numWobbles == 0) {
                        catchAction = new CatchPokemonWobbles0Times(game, null);
                    } else if (numWobbles == 1) {
                        catchAction = new CatchPokemonWobbles1Time(game, null);
                    } else if (numWobbles == 2) {
                        catchAction = new CatchPokemonWobbles2Times(game, null);
                    } else if (numWobbles == 3) {
                        catchAction = new CatchPokemonWobbles3Times(game, null);
                    } else {
                        catchAction = new CatchPokemonWobblesThenCatch(game, itemName, null);
                    }
                    playerAction = new DisplayText(game, game.player.name + " used " + itemName.toUpperCase(Locale.ROOT) + "!", (String) null, catchAction, new ThrowPokeball(game, catchAction));
                    if (numWobbles == -1) {
                        game.battle.oppPokemon.inBattle = false;
                        game.insertAction(playerAction);
                        game.actionStack.remove(this);
                        game.battle.network.turnData = null;
                        return;
                    }
                } else if (itemName.equals("silph scope")) {
                    playerAction = new DisplayText(game, game.player.name + " used " + itemName.toUpperCase(Locale.ROOT) + "!", (String) null, true, false, (Action) new SplitAction(new WaitFrames(game, 96, new CallMethod(game.battle.oppPokemon, "revealGhost", new Object[0], null)), new FadeAnim(game, 8, new SplitAction(new WaitFrames(game, 4, new PlayMusic(new Pokemon(game.battle.oppPokemon.specie.name, 10), (Action) null)), new PokemonIntroAnim(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "Enemy " + game.battle.oppPokemon.specie.name.toUpperCase(Locale.ROOT) + " was revealed!", (String) null, (Action) null, (Action) null))))))));
                } else if (itemName.contains("berry") || itemName.equals("moomoo milk") || itemName.equals("revive")) {
                    playerAction = new Action(new Object[0]) { // from class: com.corona.game.Battle.DoTurn.1
                        @Override // com.corona.game.Action
                        public String getCamera() {
                            return "gui";
                        }
                    };
                } else if (itemName.contains("poké doll")) {
                    game.player.numFlees = 0;
                    game.battle.oppPokemon.inBattle = false;
                    game.actionStack.remove(this);
                    game.insertAction(new DisplayText(game, game.player.name + " used " + itemName.toUpperCase(Locale.ROOT) + "!", (String) null, (Action) null, new SplitAction(new PlayMusic("run1", (Action) null), new WaitFrames(game, 18, new DisplayText(game, "Got away safely!", (String) null, (Action) null, new SplitAction(new BattleFadeOut(game, new SetField(game, "playerCanMove", true, null)), new BattleFadeOutMusic(game, new SetField(game.musicController, "resumeOverworldMusic", true, null))))))));
                    game.battle.network.turnData = null;
                    return;
                } else {
                    playerAction = new DisplayText(game, "Dev note - Invalid item.", (String) null, (Action) null, (Action) null);
                }
            } else if (this.type == Type.RUN) {
                if (game.type != Game.Type.CLIENT) {
                    runSuccessful = game.battle.calcIfRunSuccessful(game, game.player);
                } else {
                    runSuccessful = game.battle.network.turnData.runSuccessful;
                }
                if (runSuccessful) {
                    game.player.numFlees = 0;
                    game.battle.oppPokemon.inBattle = false;
                    game.actionStack.remove(this);
                    game.insertAction(new WaitFrames(game, 18, new DisplayText(game, "Got away safely!", (String) null, (Action) null, new SplitAction(new BattleFadeOut(game, new SetField(game, "playerCanMove", true, null)), new BattleFadeOutMusic(game, new SetField(game.musicController, "resumeOverworldMusic", true, null))))));
                    game.insertAction(new PlayMusic("run1", (Action) null));
                    game.battle.network.turnData = null;
                    return;
                }
                game.player.numFlees++;
                playerAction = new DisplayText(game, "Canì escape!", (String) null, (Action) null, new AttackAnim(game, null, true, null));
            } else {
                game.player.numFlees = 0;
                if (game.type != Game.Type.CLIENT) {
                    String attackName = game.player.currPokemon.attacks[DrawAttacksMenu.curr];
                    if (attackName == null) {
                        attackName = "struggle";
                    }
                    playerAttack = game.battle.attacks.get(attackName.toLowerCase(Locale.ROOT));
                    int yourSpeed = game.player.currPokemon.currentStats.get("speed").intValue();
                    int oppSpeed = game.battle.oppPokemon.currentStats.get("speed").intValue();
                    if (playerAttack.priority != enemyAttack.priority) {
                        enemyFirst = enemyAttack.priority > playerAttack.priority;
                    } else if (yourSpeed > oppSpeed) {
                        enemyFirst = false;
                    } else if (yourSpeed < oppSpeed) {
                        enemyFirst = true;
                    } else if (game.map.rand.nextInt(2) == 0) {
                        enemyFirst = true;
                    }
                } else {
                    Network.BattleTurnData turnData3 = game.battle.network.turnData;
                    enemyFirst = turnData3.oppFirst;
                    playerAttack = turnData3.playerAttack;
                    game.player.currPokemon.trappedBy = turnData3.playerTrappedBy;
                    game.player.currPokemon.trapCounter = turnData3.playerTrapCounter;
                }
                playerAction = new AttackAnim(game, playerAttack, true, null);
            }
            if (game.battle.network.expectPlayerSwitch) {
                game.battle.network.expectPlayerSwitch = false;
                playerAction.append(new DisplayText.Clear(game, new WaitFrames(game, 3, this.nextAction)));
                game.actionStack.remove(this);
                game.insertAction(playerAction);
                game.battle.network.turnData = null;
                return;
            }
            if (!enemyFirst) {
                doTurn = playerAction;
                doTurn.append(new DisplayText.Clear(game, new WaitFrames(game, 3, enemyAction)));
            } else {
                doTurn = enemyAction;
                doTurn.append(new DisplayText.Clear(game, new WaitFrames(game, 3, playerAction)));
            }
            Battle battle = game.battle;
            Objects.requireNonNull(battle);
            doTurn.append(new CheckWeather(game, null));
            Battle battle2 = game.battle;
            Objects.requireNonNull(battle2);
            doTurn.append(new CheckTrapped(game, null));
            Battle battle3 = game.battle;
            Objects.requireNonNull(battle3);
            doTurn.append(new CheckScreens(game, null));
            Battle battle4 = game.battle;
            Objects.requireNonNull(battle4);
            doTurn.append(new CheckLockedMoves(game, null));
            doTurn.append(new SetField(game.battle, "turnNumber", Integer.valueOf(game.battle.turnNumber + 1), null));
            doTurn.append(new DisplayText.Clear(game, new WaitFrames(game, 3, this.nextAction)));
            game.actionStack.remove(this);
            game.insertAction(doTurn);
            game.battle.network.turnData = null;
        }
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$LoadAndPlayAnimation.class */
    public static class LoadAndPlayAnimation extends Action {
        String name;
        Music sound;
        Texture currText;
        Sprite currFrame;
        Pokemon target;
        Matrix4 translation;
        Vector2 playerSpriteOrigin;
        Pixmap pixmap;
        Pixmap newPixmap;
        Texture drawTexture;
        int pixmapX;
        int pixmapY;
        Pixmap regionPixmap;
        Texture regionTexture;
        SpriteProxy regionProxy;
        public Action.Layer layer = Action.Layer.gui_103;
        HashMap<Integer, String> metadata = new HashMap<>();
        int frameNum = 1;
        boolean firstStep = true;
        Vector2 enemySpriteOrigin = new Vector2();
        int dispLastFrame = 1;
        int dispProgress = 0;
        int[][] screenRegions = {new int[]{94, 84, 66, 56}, new int[]{0, 48, 80, 48}, new int[]{0, 104, 92, 40}, new int[]{68, 48, 92, 40}};
        int inverseLastFrame = -1;
        ShaderProgram grayscaleShader = new ShaderProgram(EvolutionAnim.vertexShader, EvolutionAnim.fragmentShader);

        public LoadAndPlayAnimation(Game game, String name, Pokemon target, Action nextAction) {
            super(new Object[0]);
            this.name = name.toLowerCase(Locale.ROOT).replace(' ', '_');
            if (target == game.player.currPokemon) {
                this.name += "_enemy_gsc";
            } else if (game.battle.oppPokemon == null || target != game.battle.oppPokemon) {
                this.name += "_gsc";
            } else {
                this.name += "_player_gsc";
            }
            this.target = target;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        /* JADX DEBUG: Multi-variable search result rejected for r0v330, resolved type: com.badlogic.gdx.graphics.g2d.TextureRegion[][][][] */
        /* JADX DEBUG: Multi-variable search result rejected for r1v247, resolved type: java.lang.Object[] */
        /* JADX DEBUG: Multi-variable search result rejected for r0v411, resolved type: java.lang.Object[] */
        /* JADX DEBUG: Multi-variable search result rejected for r0v412, resolved type: java.lang.Object[] */
        /* JADX DEBUG: Multi-variable search result rejected for r4v12, resolved type: java.lang.Object[] */
        /* JADX DEBUG: Multi-variable search result rejected for r4v13, resolved type: com.badlogic.gdx.graphics.g2d.TextureAtlas$AtlasSprite */
        /* JADX DEBUG: Multi-variable search result rejected for r0v418, resolved type: com.badlogic.gdx.graphics.g2d.TextureRegion[] */
        /* JADX WARN: Multi-variable type inference failed */
        @Override // com.corona.game.Action
        public void step(Game game) {
            int progress;
            int sign;
            if (this.firstStep) {
                if (!Game.battleAnims && !this.name.contains("_effective_") && !this.name.contains("shiny_") && !this.name.contains("stat_stage_hit")) {
                    game.actionStack.remove(this);
                    game.insertAction(this.nextAction);
                    return;
                } else if (this.name.contains("crush_grip")) {
                    game.actionStack.remove(this);
                    game.insertAction(new Attack.CrushGrip(game, this.target, this.nextAction));
                    return;
                } else {
                    System.out.println(this.name);
                    try {
                        Reader reader = Gdx.files.internal("attacks/" + this.name + "/metadata.out").reader();
                        BufferedReader br = new BufferedReader(reader);
                        while (true) {
                            String line = br.readLine();
                            if (line == null) {
                                break;
                            }
                            this.metadata.put(Integer.valueOf(Integer.valueOf(line.split(", ")[0]).intValue()), line.split(", ")[1]);
                        }
                        reader.close();
                        if (!this.name.contains("evolve")) {
                            this.sound = AudioLoader.loadMusic("attacks/" + this.name + "/sound.ogg");
                            this.sound.play();
                        }
                    } catch (GdxRuntimeException e) {
                    } catch (FileNotFoundException e2) {
                        e2.printStackTrace();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                    this.firstStep = false;
                    this.playerSpriteOrigin = new Vector2(game.player.currPokemon.backSprite.getX(), game.player.currPokemon.backSprite.getY());
                    if (game.battle.oppPokemon != null) {
                        this.enemySpriteOrigin = new Vector2(game.battle.oppPokemon.sprite.getX(), game.battle.oppPokemon.sprite.getY());
                    }
                    int i = 0;
                    while (true) {
                        FileHandle filehandle = Gdx.files.internal("attacks/" + this.name + "/output/frame-" + String.format(Locale.ROOT, "%03d", Integer.valueOf(i)) + ".png");
                        if (!filehandle.exists()) {
                            break;
                        }
                        TextureCache.get(filehandle);
                        i++;
                    }
                }
            }
            DrawEnemyHealth.shouldDraw = true;
            DrawFriendlyHealth.shouldDraw = true;
            DrawBattle.shouldDrawOwnPokemon = true;
            DrawBattle.shouldDrawOppPokemon = true;
            EvolutionAnim.isGreyscale = false;
            SpriteProxy.inverseColors = false;
            SpriteProxy.darkenAllColors1 = false;
            SpriteProxy.darkenAllColors2 = false;
            SpriteProxy.darkenAllColors3 = false;
            SpriteProxy.lightenAllColors1 = false;
            SpriteProxy.lightenAllColors2 = false;
            SpriteProxy.confuseRayColors1 = false;
            SpriteProxy.confuseRayColors2 = false;
            game.player.currPokemon.backSprite.lightenColors1 = false;
            game.player.currPokemon.backSprite.lightenColors2 = false;
            game.player.currPokemon.backSprite.darkenColors1 = false;
            game.player.currPokemon.backSprite.darkenColors2 = false;
            game.player.currPokemon.backSprite.darkenColors3 = false;
            if (game.battle.oppPokemon != null) {
                game.battle.oppPokemon.sprite.lightenColors1 = false;
                game.battle.oppPokemon.sprite.lightenColors2 = false;
                game.battle.oppPokemon.sprite.darkenColors1 = false;
                game.battle.oppPokemon.sprite.darkenColors2 = false;
                game.battle.oppPokemon.sprite.darkenColors3 = false;
                game.battle.oppPokemon.sprite.setPosition(this.enemySpriteOrigin.x, this.enemySpriteOrigin.y);
            }
            game.player.currPokemon.backSprite.lightenColors2 = false;
            game.player.currPokemon.backSprite.setPosition(this.playerSpriteOrigin.x, this.playerSpriteOrigin.y);
            if (game.battle.drawAction != null) {
                game.battle.drawAction.drawEnemyHealthAction.translateAmt.set(0.0f, 0.0f);
            }
            game.uiBatch.setTransformMatrix(new Matrix4(new Vector3(0.0f, 0.0f, 0.0f), new Quaternion(), new Vector3(1.0f, 1.0f, 1.0f)));
            FileHandle filehandle2 = Gdx.files.internal("attacks/" + this.name + "/output/frame-" + String.format(Locale.ROOT, "%03d", Integer.valueOf(this.frameNum)) + ".png");
            if (!filehandle2.exists()) {
                if (this.drawTexture != null) {
                    this.drawTexture.dispose();
                }
                if (this.regionProxy != null) {
                    this.regionProxy.getTexture().dispose();
                }
                game.actionStack.remove(this);
                game.insertAction(this.nextAction);
                return;
            }
            EvolutionAnim.drawPostEvoBottom = false;
            EvolutionAnim.drawPostEvoTop = false;
            if (Game.photosensitiveMode && this.metadata.containsKey(Integer.valueOf(this.frameNum))) {
                String properties = this.metadata.get(Integer.valueOf(this.frameNum));
                if (this.inverseLastFrame == -1 && properties.contains("inverse_colors")) {
                    this.inverseLastFrame = this.frameNum;
                } else if (this.inverseLastFrame > -1 && !properties.contains("inverse_colors")) {
                    if (this.frameNum - this.inverseLastFrame < 20) {
                        this.metadata.put(Integer.valueOf(this.frameNum), properties + " inverse_colors");
                    } else {
                        this.inverseLastFrame = -1;
                    }
                }
            }
            if (this.metadata.containsKey(Integer.valueOf(this.frameNum))) {
                String properties2 = this.metadata.get(Integer.valueOf(this.frameNum));
                if (properties2.contains("screenshot")) {
                    String[] values = properties2.split("screenshot:")[1].split(" ")[0].split(",");
                    this.pixmapX = Integer.valueOf(values[0]).intValue();
                    this.pixmapY = Integer.valueOf(values[1]).intValue();
                    int offsetX = (int) ((game.currScreen.x - ((160.0f * game.currScreen.y) / 144.0f)) / 2.0f);
                    this.pixmap = ScreenUtils.getFrameBufferPixmap(offsetX, 0, ((int) game.currScreen.x) - (offsetX * 2), (int) game.currScreen.y);
                    float heightM = game.currScreen.y / 144.0f;
                    this.newPixmap = new Pixmap((int) (((float) this.pixmap.getWidth()) / heightM), (int) (((float) this.pixmap.getHeight()) / heightM), Pixmap.Format.RGBA8888);
                    this.newPixmap.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
                    this.drawTexture = new Texture(this.newPixmap);
                }
                if (properties2.contains("row_copy") || properties2.contains("row_displace") || properties2.contains("row_split")) {
                    float heightM2 = game.currScreen.y / 144.0f;
                    this.newPixmap.fill();
                    for (int i2 = 0; i2 < this.newPixmap.getWidth(); i2++) {
                        for (int j = 0; j < this.newPixmap.getHeight(); j++) {
                            this.newPixmap.drawPixel(i2, j, Color.rgba8888(new Color(this.pixmap.getPixel((int) (((float) i2) * heightM2), (int) (((float) j) * heightM2)))));
                        }
                    }
                    boolean playerSpriteIgnore = this.name.contains("player") && !this.name.contains("surf") && !this.name.contains("whirlpool");
                    boolean enemySpriteIgnore = this.name.contains("enemy") && !this.name.contains("surf") && !this.name.contains("whirlpool");
                    if (properties2.contains("row_copy")) {
                        int i3 = 0;
                        for (String copy : properties2.split(" row_copy:")) {
                            String copy2 = copy.split(" ")[0];
                            i3++;
                            if (i3 != 1) {
                                int targetY = Integer.valueOf(copy2.split(",")[0]).intValue();
                                int sourceY = Integer.valueOf(copy2.split(",")[1]).intValue();
                                for (int x = 0; x < this.newPixmap.getWidth(); x++) {
                                    if ((!playerSpriteIgnore || x >= 86 || 144 - targetY >= 112) && (!enemySpriteIgnore || x < 96 || 144 - targetY < 88)) {
                                        this.newPixmap.drawPixel(x, 144 - targetY, Color.rgba8888(new Color(this.pixmap.getPixel((int) (((float) x) * heightM2), (int) (((float) (144 - sourceY)) * heightM2)))));
                                    }
                                }
                            }
                        }
                    }
                    if (properties2.contains("row_displace")) {
                        if (((double) this.frameNum) >= ((double) this.dispLastFrame) + (1.0d / Double.valueOf(properties2.split("row_displace:")[1].split(" ")[0]).doubleValue())) {
                            this.dispLastFrame = this.frameNum;
                            this.dispProgress++;
                        }
                        boolean playerSpriteIgnore2 = false;
                        boolean enemySpriteIgnore2 = false;
                        if (properties2.contains("displace_target")) {
                            String disp_target = properties2.split("displace_target:")[1].split(" ")[0];
                            if (disp_target.contains("enemy")) {
                                playerSpriteIgnore2 = true;
                            } else if (disp_target.contains("player")) {
                                enemySpriteIgnore2 = true;
                            }
                        }
                        for (int y = 48; y < this.newPixmap.getHeight(); y++) {
                            if ((!playerSpriteIgnore2 || y >= 88) && (!enemySpriteIgnore2 || y < 92)) {
                                int shift = (int) (5.0d * Math.sin(0.5235987755982988d * ((double) (y + this.dispProgress))));
                                for (int x2 = 0; x2 < this.newPixmap.getWidth(); x2++) {
                                    if ((!playerSpriteIgnore2 || x2 >= 86) && (!enemySpriteIgnore2 || x2 < 96)) {
                                        this.newPixmap.drawPixel(x2 + shift, y, Color.rgba8888(new Color(this.pixmap.getPixel((int) (((float) x2) * heightM2), (int) (((float) y) * heightM2)))));
                                    }
                                }
                            }
                        }
                    }
                    if (properties2.contains("row_split")) {
                        int progress2 = Integer.valueOf(properties2.split("row_split:")[1].split(" ")[0]).intValue();
                        boolean playerSpriteIgnore3 = this.name.contains("enemy");
                        boolean enemySpriteIgnore3 = this.name.contains("player");
                        for (int y2 = 48; y2 < this.newPixmap.getHeight(); y2++) {
                            if (y2 % 2 == 0) {
                                sign = -1;
                            } else {
                                sign = 1;
                            }
                            if ((!playerSpriteIgnore3 || y2 >= 88) && (!enemySpriteIgnore3 || y2 < 92)) {
                                for (int x3 = 0; x3 < this.newPixmap.getWidth(); x3++) {
                                    if ((!playerSpriteIgnore3 || x3 >= 86) && (!enemySpriteIgnore3 || x3 < 96)) {
                                        this.newPixmap.drawPixel(x3 + (progress2 * sign), y2, Color.rgba8888(new Color(this.pixmap.getPixel((int) (((float) x3) * heightM2), (int) (((float) y2) * heightM2)))));
                                    }
                                }
                            }
                        }
                    }
                    this.drawTexture.draw(this.newPixmap, 0, 0);
                    game.uiBatch.draw(this.drawTexture, 0.0f, 0.0f, (float) this.drawTexture.getWidth(), (float) this.drawTexture.getHeight(), 0, 0, this.drawTexture.getWidth(), this.drawTexture.getHeight(), false, true);
                    if (properties2.contains(" darken_effect1")) {
                        SpriteProxy.darkenAllColors1 = true;
                    }
                    if (properties2.contains(" darken_effect2")) {
                        SpriteProxy.darkenAllColors2 = true;
                    }
                    if (properties2.contains(" darken_effect3")) {
                        SpriteProxy.darkenAllColors3 = true;
                    }
                    if (properties2.contains(" lighten_effect1")) {
                        SpriteProxy.lightenAllColors1 = true;
                    }
                    if (properties2.contains(" lighten_effect2")) {
                        SpriteProxy.lightenAllColors2 = true;
                    }
                    if (properties2.contains(" inverse_colors")) {
                        SpriteProxy.inverseColors = true;
                    }
                    if (SpriteProxy.darkenAllColors1 || SpriteProxy.darkenAllColors2 || SpriteProxy.darkenAllColors3 || SpriteProxy.lightenAllColors1 || SpriteProxy.lightenAllColors2 || SpriteProxy.inverseColors) {
                        if (properties2.contains(" inverse_colors")) {
                            this.regionPixmap = new Pixmap(160, 96, Pixmap.Format.RGBA8888);
                            this.regionPixmap.setColor(Color.BLACK);
                            this.regionPixmap.fill();
                            this.regionTexture = new Texture(this.regionPixmap);
                            game.uiBatch.draw(this.regionTexture, 0.0f, 48.0f, (float) this.regionTexture.getWidth(), (float) this.regionTexture.getHeight(), 0, 0, this.regionTexture.getWidth(), this.regionTexture.getHeight(), false, false);
                        }
                        for (int r = 0; r < this.screenRegions.length; r++) {
                            String colors = "";
                            int numColors = 0;
                            this.regionPixmap = new Pixmap(this.screenRegions[r][2], this.screenRegions[r][3], Pixmap.Format.RGBA8888);
                            this.regionPixmap.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
                            this.regionPixmap.fill();
                            for (int i4 = 0; i4 < this.regionPixmap.getWidth(); i4++) {
                                for (int j2 = 0; j2 < this.regionPixmap.getHeight(); j2++) {
                                    Color color = new Color(this.newPixmap.getPixel(this.screenRegions[r][0] + i4, this.screenRegions[r][1] + j2));
                                    if (((double) color.r) != 1.0d || color.g < 0.0f || ((double) color.b) != 1.0d) {
                                        this.regionPixmap.drawPixel(i4, j2, Color.rgba8888(color));
                                        if (!colors.contains(color.toString())) {
                                            colors = colors + " " + color.toString();
                                            numColors++;
                                        }
                                    } else if (properties2.contains(" inverse_colors") && ((double) color.r) == 1.0d && ((double) color.g) == 1.0d && ((double) color.b) == 1.0d) {
                                        this.regionPixmap.drawPixel(i4, j2, Color.rgba8888(color));
                                    }
                                }
                            }
                            if (numColors > 1) {
                                this.regionTexture = new Texture(this.regionPixmap);
                                this.regionProxy = new SpriteProxy(this.regionTexture, 0, 0, this.screenRegions[r][2], this.screenRegions[r][3]);
                                if (this.regionProxy.color1 != null) {
                                    this.regionProxy.flip(false, true);
                                    this.regionProxy.setPosition((float) this.screenRegions[r][0], (float) this.screenRegions[r][1]);
                                    this.regionProxy.draw(game.uiBatch);
                                }
                            }
                        }
                        this.regionPixmap.dispose();
                        this.regionTexture.dispose();
                    }
                }
            }
            if (this.metadata.containsKey(Integer.valueOf(this.frameNum))) {
                String properties3 = this.metadata.get(Integer.valueOf(this.frameNum));
                if (properties3.contains("player_shrink") || properties3.contains("enemy_shrink")) {
                    Sprite baseSprite = game.player.currPokemon.backSprite;
                    Vector2 position = new Vector2(0.0f, 48.0f);
                    if (properties3.contains("enemy_shrink")) {
                        baseSprite = game.battle.oppPokemon.sprite;
                        progress = Integer.valueOf(properties3.split("enemy_shrink:")[1].split(" ")[0]).intValue();
                        position.x = game.battle.oppPokemon.sprite.getX() - (56.0f - game.battle.oppPokemon.sprite.getWidth());
                        position.y = game.battle.oppPokemon.sprite.getY();
                    } else {
                        progress = Integer.valueOf(properties3.split("player_shrink:")[1].split(" ")[0]).intValue();
                    }
                    TextureRegion[][] tempRegion = new Sprite(baseSprite).split(8, 8);
                    TextureRegion[][][][] textureRegionArr = new TextureRegion[7][7][];
                    int offsetX2 = 7 - tempRegion.length;
                    for (int i5 = 0; i5 < tempRegion.length; i5++) {
                        for (int j3 = 0; j3 < tempRegion[i5].length; j3++) {
                            textureRegionArr[i5][j3 + offsetX2] = tempRegion[i5][j3];
                        }
                    }
                    Object[][] objArr = new Sprite[7][7][];
                    for (int i6 = 0; i6 < textureRegionArr.length; i6++) {
                        for (int j4 = 0; j4 < textureRegionArr[i6].length; j4++) {
                            if (textureRegionArr[6 - j4][i6] != 0) {
                                objArr[i6][j4] = new Sprite((TextureRegion) textureRegionArr[6 - j4][i6]);
                            }
                        }
                    }
                    for (int i7 = 0; i7 < objArr.length; i7++) {
                        objArr[i7][1] = objArr[i7][2];
                        objArr[i7][2] = objArr[i7][3];
                        objArr[i7][3] = objArr[i7][5];
                        objArr[i7][4] = null;
                        objArr[i7][5] = null;
                    }
                    objArr[2] = objArr[1];
                    objArr[1] = new Sprite[0];
                    objArr[5] = objArr[6];
                    objArr[6] = new Sprite[0];
                    Sprite[][][] drawSprite = {objArr, 0, 0};
                    if (progress == 2) {
                        Object[][] objArr2 = new Sprite[7][7][];
                        for (int i8 = 0; i8 < objArr.length; i8++) {
                            for (int j5 = 0; j5 < objArr[i8].length; j5++) {
                                objArr2[i8][j5] = objArr[i8][j5];
                            }
                        }
                        for (int i9 = 0; i9 < objArr2.length; i9++) {
                            if (objArr2[i9].length > 0) {
                                objArr2[i9][1] = objArr2[i9][3];
                                objArr2[i9][2] = null;
                                objArr2[i9][3] = null;
                                objArr2[i9][4] = null;
                                objArr2[i9][5] = null;
                            }
                        }
                        objArr2[3] = objArr2[2];
                        objArr2[2] = new Sprite[0];
                        objArr2[4] = objArr2[5];
                        objArr2[5] = new Sprite[0];
                        objArr2[6] = new Sprite[0];
                        drawSprite = new Sprite[][][]{objArr2, 0, 0};
                    }
                    for (int k = 0; k < drawSprite.length; k++) {
                        if (drawSprite[k] != null) {
                            for (int i10 = 0; i10 < drawSprite[k].length; i10++) {
                                for (int j6 = 0; j6 < drawSprite[k][i10].length; j6++) {
                                    if (drawSprite[k][i10][j6] != null) {
                                        drawSprite[k][i10][j6].setPosition((position.x + ((float) (8 * i10))) - ((float) (4 * k)), (position.y + ((float) (8 * j6))) - ((float) (8 * k)));
                                        drawSprite[k][i10][j6].draw(game.uiBatch);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            this.currText = TextureCache.get(filehandle2);
            this.currFrame = new Sprite(this.currText, 0, 0, 160, 144);
            this.currFrame.draw(game.uiBatch);
            if (this.metadata.containsKey(Integer.valueOf(this.frameNum))) {
                String properties4 = this.metadata.get(Integer.valueOf(this.frameNum));
                if (properties4.contains("enemy_healthbar_gone")) {
                    DrawEnemyHealth.shouldDraw = false;
                }
                if (properties4.contains("player_healthbar_gone")) {
                    DrawFriendlyHealth.shouldDraw = false;
                }
                if (properties4.contains("player_sprite_gone")) {
                    DrawBattle.shouldDrawOwnPokemon = false;
                }
                if (properties4.contains("enemy_sprite_gone")) {
                    DrawBattle.shouldDrawOppPokemon = false;
                }
                if (properties4.contains("player_sprite_hide")) {
                    DrawBattle.hideOwnPokemon = true;
                }
                if (properties4.contains("enemy_sprite_hide")) {
                    DrawBattle.hideOppPokemon = true;
                }
                if (properties4.contains("player_sprite_show")) {
                    DrawBattle.hideOwnPokemon = false;
                }
                if (properties4.contains("enemy_sprite_show")) {
                    DrawBattle.hideOppPokemon = false;
                }
                if (properties4.contains("screen_translate_y")) {
                    game.uiBatch.setTransformMatrix(new Matrix4(new Vector3(0.0f, (float) Integer.valueOf(properties4.split("screen_translate_y:")[1].split(" ")[0]).intValue(), 0.0f), new Quaternion(), new Vector3(1.0f, 1.0f, 1.0f)));
                }
                if (properties4.contains("screen_translate_x")) {
                    game.uiBatch.setTransformMatrix(new Matrix4(new Vector3((float) Integer.valueOf(properties4.split("screen_translate_x:")[1].split(" ")[0]).intValue(), 0.0f, 0.0f), new Quaternion(), new Vector3(1.0f, 1.0f, 1.0f)));
                }
                if (properties4.contains("player_translate_x")) {
                    game.player.currPokemon.backSprite.setPosition(game.player.currPokemon.backSprite.getX() + ((float) Integer.valueOf(properties4.split("player_translate_x:")[1].split(" ")[0]).intValue()), game.player.currPokemon.backSprite.getY());
                }
                if (properties4.contains("player_translate_y")) {
                    game.player.currPokemon.backSprite.setPosition(game.player.currPokemon.backSprite.getX(), game.player.currPokemon.backSprite.getY() + ((float) Integer.valueOf(properties4.split("player_translate_y:")[1].split(" ")[0]).intValue()));
                }
                if (properties4.contains("enemy_translate_x")) {
                    int translateAmt = Integer.valueOf(properties4.split("enemy_translate_x:")[1].split(" ")[0]).intValue();
                    game.battle.oppPokemon.sprite.setPosition(game.battle.oppPokemon.sprite.getX() + ((float) translateAmt), game.battle.oppPokemon.sprite.getY());
                    game.battle.drawAction.drawEnemyHealthAction.translateAmt.set((float) translateAmt, 0.0f);
                }
                if (properties4.contains("enemy_sprite_translate_x")) {
                    game.battle.oppPokemon.sprite.setPosition(game.battle.oppPokemon.sprite.getX() + ((float) Integer.valueOf(properties4.split("enemy_sprite_translate_x:")[1].split(" ")[0]).intValue()), game.battle.oppPokemon.sprite.getY());
                }
                if (properties4.contains("enemy_translate_y")) {
                    game.battle.oppPokemon.sprite.setPosition(game.battle.oppPokemon.sprite.getX(), game.battle.oppPokemon.sprite.getY() + ((float) Integer.valueOf(properties4.split("enemy_translate_y:")[1].split(" ")[0]).intValue()));
                }
                if (properties4.contains("evo_top_sprite_changed")) {
                    EvolutionAnim.drawPostEvoTop = true;
                }
                if (properties4.contains("evo_bottom_sprite_changed")) {
                    EvolutionAnim.drawPostEvoBottom = true;
                }
                if (properties4.contains("draw_hatch_bottom_sprite")) {
                    EggHatchAnim.drawPostHatchBottom = true;
                }
                if (properties4.contains("draw_hatch_top_sprite")) {
                    EggHatchAnim.drawPostHatchTop = true;
                }
                if (properties4.contains("sprite_greyscale")) {
                    EvolutionAnim.isGreyscale = true;
                }
                if (properties4.contains(" darken_effect1")) {
                    SpriteProxy.darkenAllColors1 = true;
                }
                if (properties4.contains(" darken_effect2")) {
                    SpriteProxy.darkenAllColors2 = true;
                }
                if (properties4.contains(" darken_effect3")) {
                    SpriteProxy.darkenAllColors3 = true;
                }
                if (properties4.contains("confuseray_effect1")) {
                    SpriteProxy.confuseRayColors1 = true;
                }
                if (properties4.contains("confuseray_effect2")) {
                    SpriteProxy.confuseRayColors2 = true;
                }
                if (properties4.contains(" lighten_effect1")) {
                    SpriteProxy.lightenAllColors1 = true;
                }
                if (properties4.contains(" lighten_effect2")) {
                    SpriteProxy.lightenAllColors2 = true;
                }
                if (properties4.contains("player_lighten_effect1")) {
                    game.player.currPokemon.backSprite.lightenColors1 = true;
                }
                if (properties4.contains("player_lighten_effect2")) {
                    game.player.currPokemon.backSprite.lightenColors2 = true;
                }
                if (properties4.contains("enemy_lighten_effect1")) {
                    game.battle.oppPokemon.sprite.lightenColors1 = true;
                }
                if (properties4.contains("enemy_lighten_effect2")) {
                    game.battle.oppPokemon.sprite.lightenColors2 = true;
                }
                if (properties4.contains("player_darken_effect1")) {
                    game.player.currPokemon.backSprite.darkenColors1 = true;
                }
                if (properties4.contains("player_darken_effect2")) {
                    game.player.currPokemon.backSprite.darkenColors2 = true;
                }
                if (properties4.contains("player_darken_effect3")) {
                    game.player.currPokemon.backSprite.darkenColors3 = true;
                }
                if (properties4.contains("enemy_darken_effect1")) {
                    game.battle.oppPokemon.sprite.darkenColors1 = true;
                }
                if (properties4.contains("enemy_darken_effect2")) {
                    game.battle.oppPokemon.sprite.darkenColors2 = true;
                }
                if (properties4.contains("enemy_darken_effect3")) {
                    game.battle.oppPokemon.sprite.darkenColors3 = true;
                }
                if (properties4.contains("play_evo_fanfare")) {
                    EvolutionAnim.playSound = true;
                }
                if (properties4.contains("inverse_colors")) {
                    SpriteProxy.inverseColors = true;
                }
                if (properties4.contains("user_cry")) {
                    if (this.sound != null) {
                        this.sound.dispose();
                    }
                    Pokemon user = game.player.currPokemon;
                    if (this.target == game.player.currPokemon) {
                        user = game.battle.oppPokemon;
                    }
                    this.sound = AudioLoader.loadMusic("pokemon/cries/" + user.dexNumber + ".ogg");
                    this.sound.play();
                }
            }
            this.frameNum++;
        }
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$Network.class */
    public class Network {
        Network.BattleTurnData turnData;
        boolean expectPlayerSwitch = false;

        public Network() {
            Battle.this = this$0;
        }
    }

    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/Battle$WaitTurnData.class */
    public static class WaitTurnData extends Action {
        Action text;

        public WaitTurnData(Game game, Action nextAction) {
            super(new Object[0]);
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void firstStep(Game game) {
            DisplayText.textPersist = false;
            this.text = new DisplayText(game, "Waiting for server...", (String) null, true, false, (Action) null);
            game.insertAction(this.text);
            this.text.step(game);
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return Action.Layer.gui_500;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            if (game.battle.network.turnData != null) {
                game.actionStack.remove(this.text);
                DisplayText.textPersist = false;
                game.actionStack.remove(this);
                game.insertAction(this.nextAction);
            }
        }
    }
}
